:root {
  --bg: #000000;
  --panel: #0f0f0f;
  --panel-dark: #050505;
  --card: #111111;
  --input: #0b0b0b;
  --line: #6f3a16;
  --text: #fff8f1;
  --muted: #ffc18f;
  --green: #56eb8a;
  --red: #ff6f88;
  --blue: #ff7a1a;
  --accent-orange: #ff6a1a;
  --accent-orange-soft: rgba(255, 106, 26, 0.24);
  --accent-orange-glow: rgba(255, 106, 26, 0.18);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  min-height: 100%;
  background: #000000;
  color: var(--text);
  font-family: "Inter", "Segoe UI", sans-serif;
  overflow-x: hidden;
  overflow-y: auto;
}

.app-shell .hidden,
.modal .hidden,
.modal.hidden {
  display: none !important;
}

.app-shell {
  display: flex;
  gap: 14px;
  padding: 12px 14px 14px;
  min-height: 100%;
}

.left-panel {
  width: 334px;
  background: var(--panel);
  border: 1px solid rgba(255, 106, 26, 0.34);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  box-shadow:
    inset 0 1px 0 rgba(255, 106, 26, 0.18),
    0 0 0 1px rgba(255, 106, 26, 0.08);
}

.right-panel {
  flex: 1;
  background: var(--panel-dark);
  border: 1px solid rgba(255, 106, 26, 0.28);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
  box-shadow:
    inset 0 1px 0 rgba(255, 106, 26, 0.18),
    0 0 0 1px rgba(255, 106, 26, 0.07);
}

.mode-switch {
  display: flex;
  gap: 6px;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
}

.mode-btn {
  flex: 1;
  border: 1px solid #8a431a;
  border-radius: 10px;
  background: #111111;
  color: #ffd9bf;
  padding: 9px 8px;
  font-weight: 600;
  cursor: pointer;
}

.mode-btn.active {
  background: linear-gradient(180deg, #ff8b1f 0%, #ff6a00 100%);
  border-color: rgba(255, 127, 64, 0.7);
  box-shadow:
    inset 0 0 0 1px rgba(255, 106, 26, 0.32),
    0 0 0 1px rgba(255, 106, 26, 0.18);
  color: #fff;
}

.field-label {
  color: #ffd2ad;
  font-size: 13px;
  font-weight: 600;
}

.field-label.inline {
  margin-right: 6px;
}

.app-shell input,
.app-shell select,
.app-shell .display-input,
.modal input,
.modal select {
  background: var(--input);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 14px;
}

.app-shell input:not([type="range"]):focus,
.app-shell select:focus,
.modal input:focus,
.modal select:focus {
  outline: none;
  border-color: rgba(255, 106, 26, 0.72);
  box-shadow: 0 0 0 2px var(--accent-orange-glow);
}

.app-shell input[type="number"]::-webkit-outer-spin-button,
.app-shell input[type="number"]::-webkit-inner-spin-button,
.modal input[type="number"]::-webkit-outer-spin-button,
.modal input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.display-input {
  width: 100%;
}

.mode-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.amount-row {
  display: flex;
  align-items: center;
  gap: 6px;
  background: #171717;
  border: 1px solid #8e451b;
  border-radius: 10px;
  padding: 6px;
}

.amount-row input {
  flex: 1;
}

.currency-badge {
  width: 18px;
  height: 18px;
  border-radius: 9px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #ff8f1f;
  color: #1a0d00;
  font-weight: 700;
  font-size: 12px;
}

.quick-btn,
.count-btn {
  min-width: 34px;
  text-align: center;
  background: #1c1c1c;
  border: 1px solid #a4511f;
  border-radius: 10px;
  border-color: #a4511f;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, color 160ms ease;
}

.quick-btn:hover,
.count-btn:hover {
  border-color: rgba(255, 106, 26, 0.65);
  box-shadow: 0 0 0 1px var(--accent-orange-soft);
  color: #fff3e8;
}

.count-btn.active {
  background: #ff7a1a;
  border-color: #ffb26e;
}

.play-btn {
  background: linear-gradient(180deg, #ff9728 0%, #ff6a00 100%);
  border: 1px solid rgba(255, 127, 64, 0.68);
  color: #fff;
  border-radius: 10px;
  padding: 10px;
  font-size: 24px;
  font-weight: 700;
  cursor: pointer;
  box-shadow:
    0 4px 14px rgba(255, 106, 26, 0.35),
    0 0 0 1px rgba(255, 106, 26, 0.2),
    0 0 16px rgba(255, 106, 26, 0.22);
}

.play-btn.small {
  font-size: 14px;
  padding: 9px 12px;
}

.play-btn.stop {
  background: #cc3d3d;
}

.secondary-btn {
  background: #171717;
  border: 1px solid rgba(255, 120, 54, 0.5);
  border-radius: 10px;
  color: #ffe2cc;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 160ms ease, box-shadow 160ms ease, color 160ms ease;
  box-shadow: 0 0 0 1px rgba(255, 106, 26, 0.08);
}

.secondary-btn:hover {
  border-color: rgba(255, 106, 26, 0.65);
  box-shadow: 0 0 0 1px var(--accent-orange-soft);
  color: #fff3e8;
}

.secondary-btn.small {
  padding: 7px 10px;
  font-size: 13px;
}

.inline-row {
  display: flex;
  gap: 6px;
}

.inline-row > * {
  flex: 1;
}

.speed-row {
  background: #171717;
  border: 1px solid #8e451b;
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.speed-row input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
}

.speed-row input[type="range"]::-webkit-slider-runnable-track {
  height: 10px;
  border-radius: 7px;
  background: linear-gradient(to right, #ffc48b 0%, #ff8d2e 45%, #ff5a2b 100%);
}

.speed-row input[type="range"]::-moz-range-track {
  height: 10px;
  border-radius: 7px;
  background: linear-gradient(to right, #ffc48b 0%, #ff8d2e 45%, #ff5a2b 100%);
}

.speed-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  margin-top: -4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid #ffb77b;
  background: #ff8a2a;
}

.speed-row input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 1px solid #ffb77b;
  background: #ff8a2a;
}

.speed-labels {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 12px;
}

.validation-message {
  min-height: 18px;
  color: #ff8da0;
  font-size: 12px;
}

.wallet-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.wallet-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #0d0d0d;
  border: 1px solid #8a4017;
  border-radius: 8px;
  padding: 6px 8px;
}

.wallet-chip input {
  border: none;
  background: transparent;
  font-size: 28px;
  font-weight: 700;
  min-width: 140px;
  padding: 2px 0;
  text-align: center;
}

.slider-card {
  --bar-inset: 21px;
  background: #0a0a0a;
  border: 1px solid rgba(255, 106, 26, 0.24);
  border-radius: 10px;
  padding: 10px 16px 18px;
  overflow: visible;
  box-shadow:
    inset 0 1px 0 rgba(255, 106, 26, 0.18),
    0 0 14px rgba(255, 106, 26, 0.08);
}

.marks-row {
  display: flex;
  justify-content: space-between;
  margin: 0 var(--bar-inset) -8px;
  padding-bottom: 0;
  font-weight: 700;
  position: relative;
  z-index: 4;
}

.marks-row span {
  position: relative;
  line-height: 1;
}

.marks-row span::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 18px;
  width: 2px;
  height: 22px;
  border-radius: 1px;
  background: #ff9f5b;
  opacity: 0.9;
}

.range-wrap {
  position: relative;
  padding-top: 24px;
  z-index: 8;
  overflow: visible;
}

.range-wrap input[type="range"] {
  --cutoff: 50%;
  --left-color: #ff2d56;
  --right-color: #2ae85d;
  width: 100%;
  appearance: none;
  height: 56px;
  border-radius: 28px;
  border: 1px solid #84411a;
  background:
    linear-gradient(
      to right,
      var(--left-color) 0%,
      var(--left-color) var(--cutoff),
      var(--right-color) var(--cutoff),
      var(--right-color) 100%
    ) center / calc(100% - (var(--bar-inset) * 2)) 10px no-repeat,
    #171717;
  outline: none;
  box-shadow: inset 0 0 0 1px #5f3418;
  position: relative;
  z-index: 1;
}

.range-wrap input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 34px;
  height: 38px;
  border-radius: 6px;
  background:
    linear-gradient(
      to right,
      transparent 0 10px,
      #b4551f 10px 12px,
      transparent 12px 15px,
      #b4551f 15px 17px,
      transparent 17px 20px,
      #b4551f 20px 22px,
      transparent 22px 100%
    ),
    #ff7a1a;
  border: 1px solid #ffb26e;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.range-wrap input[type="range"]::-moz-range-thumb {
  width: 34px;
  height: 38px;
  border-radius: 6px;
  background:
    linear-gradient(
      to right,
      transparent 0 10px,
      #b4551f 10px 12px,
      transparent 12px 15px,
      #b4551f 15px 17px,
      transparent 17px 20px,
      #b4551f 20px 22px,
      transparent 22px 100%
    ),
    #ff7a1a;
  border: 1px solid #ffb26e;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.35);
  cursor: pointer;
}

.result-dial {
  position: absolute;
  top: -38px;
  transform: translateX(-50%);
  width: 82px;
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #17b965;
  padding: 0;
  font-weight: 700;
  font-size: 22px;
  transition: left 180ms ease-out;
  z-index: 20;
  pointer-events: none;
}

.result-dial::before {
  content: "";
  position: absolute;
  inset: 0;
  background: #ecf1f7;
  border: 1px solid #d8dfe8;
  clip-path: polygon(20% 0, 80% 0, 100% 22%, 100% 70%, 50% 100%, 0 70%, 0 22%);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.38);
  z-index: -1;
}

.result-dial::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  bottom: -9px;
  width: 32px;
  height: 8px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.34);
  filter: blur(1.2px);
  z-index: -2;
}

.result-dial.loss {
  color: #ff345a;
}

.result-dial.roll-pop {
  animation: rollPop 220ms ease-out;
}

@keyframes rollPop {
  0% {
    transform: translateX(-50%) translateY(-8px) scale(0.95);
    opacity: 0.75;
  }
  100% {
    transform: translateX(-50%) translateY(0) scale(1);
    opacity: 1;
  }
}

.target-row input {
  flex: 1 1 auto;
}

.target-row #flipModeBtn {
  flex: 0 0 86px;
  min-width: 86px;
  max-width: 86px;
  padding: 6px 8px;
}

.last-roll {
  text-align: center;
  margin: 0;
  font-size: 22px;
}

.last-roll.win {
  color: var(--green);
}

.last-roll.loss {
  color: var(--red);
}

.stats-card,
.history-card,
.live-card {
  background: var(--card);
  border: 1px solid rgba(255, 106, 26, 0.28);
  border-radius: 10px;
  padding: 12px;
  box-shadow:
    inset 0 1px 0 rgba(255, 106, 26, 0.2),
    0 0 12px rgba(255, 106, 26, 0.07);
}

.stats-card {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.control-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-row select {
  min-width: 170px;
}

.spacer {
  flex: 1;
}

.muted {
  color: var(--muted);
}

#rtpLabel {
  color: #ffd8c2;
  font-weight: 600;
}

.bottom-row {
  display: grid;
  grid-template-columns: 2fr 1fr;
  gap: 10px;
  min-height: 0;
  flex: 1;
}

.history-card h3,
.live-card h3 {
  margin: 0 0 8px;
  color: #ffb081;
  text-shadow: 0 0 8px rgba(255, 106, 26, 0.18);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th,
td {
  border: 1px solid #6e3515;
  padding: 6px;
  text-align: center;
}

th {
  background: linear-gradient(180deg, #2b1a10 0%, #24150d 100%);
  box-shadow: inset 0 1px 0 rgba(255, 106, 26, 0.14);
}

.result-win {
  color: var(--green);
}

.result-loss {
  color: var(--red);
}

.live-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.metrics-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  background: #0f0f0f;
  border: 1px solid #84411a;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 8px;
}

.metric {
  font-size: 24px;
  font-weight: 700;
}

.metric-sub {
  font-size: 22px;
  margin-top: 2px;
}

.metric.neutral {
  color: #ffe7d3;
}

.metric.win {
  color: var(--green);
}

.metric.loss {
  color: var(--red);
}

#plGraph {
  width: 100%;
  height: 220px;
  background: #0a0a0a;
  border: 1px solid #84411a;
  border-radius: 8px;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.86);
  display: grid;
  place-items: center;
  z-index: 100;
}

.modal-card {
  width: min(440px, 92vw);
  background: #111111;
  border: 1px solid #8a4017;
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.modal-card.wide {
  width: min(820px, 96vw);
  max-height: 90vh;
  overflow: auto;
}

.modal-card h3 {
  margin: 0 0 6px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 6px;
}

.condition-blocks {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 6px;
}

.condition-card {
  background: #151515;
  border: 1px solid #8a4017;
  border-radius: 10px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.condition-head {
  display: flex;
  align-items: center;
  gap: 8px;
}

.condition-head h4 {
  margin: 0;
}

.condition-head .spacer {
  flex: 1;
}

.condition-card .inline-row > label {
  flex: 0 0 120px;
  display: flex;
  align-items: center;
  color: #ffd3b1;
  font-weight: 600;
}

.row-toggle {
  display: flex;
  gap: 14px;
}

@media (max-width: 1080px) {
  body {
    overflow: auto;
  }

  .app-shell {
    flex-direction: column;
    height: auto;
    min-height: 100%;
  }

  .left-panel {
    width: 100%;
  }

  .bottom-row {
    grid-template-columns: 1fr;
  }
}
