:root {
  color-scheme: light;
  --body: #e9edf0;
  --case: #91ae43;
  --case-dark: #6d852d;
  --case-edge: #c0d66c;
  --face: #1b1d1f;
  --face-2: #25282b;
  --groove: #08090a;
  --slot: #383c3e;
  --slot-dark: #1d2022;
  --screen: #2d3235;
  --segment: #e9ece7;
  --segment-off: rgba(255, 255, 255, 0.12);
  --orange: #ec6d2d;
  --green: #63ff4f;
  --white: #f7f6ef;
  --ink: #111315;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 28% 14%, rgba(255, 255, 255, 0.78), rgba(255, 255, 255, 0) 34%),
    linear-gradient(155deg, #f5f6f6, var(--body));
  color: var(--ink);
}

button {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
}

.decoder {
  position: relative;
  width: min(100%, 430px);
  height: min(820px, calc(100svh - 20px));
  min-height: 620px;
  display: grid;
  align-items: stretch;
  filter: drop-shadow(0 24px 45px rgba(25, 29, 30, 0.3));
}

.machine {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: clamp(8px, 2svh, 14px);
  padding: clamp(16px, 4vw, 24px);
  border-radius: 24px 24px 16px 16px;
  background:
    linear-gradient(135deg, var(--case-edge), transparent 26%),
    linear-gradient(320deg, rgba(37, 47, 19, 0.38), transparent 28%),
    var(--case);
  box-shadow:
    inset 9px 9px 0 rgba(255, 255, 255, 0.18),
    inset -10px -10px 0 rgba(44, 55, 17, 0.24),
    inset 0 0 0 2px rgba(57, 72, 20, 0.28);
  overflow: hidden;
}

.face {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(58px, 16vw, 78px);
  gap: clamp(8px, 2.4vw, 12px);
  padding: clamp(10px, 3vw, 14px);
  border-radius: 12px;
  background: var(--face);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.04),
    inset 0 -10px 22px rgba(0, 0, 0, 0.36);
}

.board-panel {
  min-width: 0;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  padding: clamp(8px, 2vw, 12px);
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.035), transparent),
    #222527;
}

.board {
  min-height: 0;
  display: grid;
  grid-template-rows: repeat(7, minmax(0, 1fr));
  gap: clamp(7px, 1.5svh, 10px);
}

.guess-row {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(8px, 3vw, 16px);
  padding-inline: clamp(4px, 1.5vw, 8px);
}

.lamp,
.slot-button {
  position: relative;
  width: min(100%, 48px);
  aspect-ratio: 0.78;
  justify-self: center;
  border: 0;
  border-radius: 4px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.14), rgba(255, 255, 255, 0) 24%),
    var(--slot);
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.08),
    inset 0 -5px 0 rgba(0, 0, 0, 0.28),
    0 5px 0 rgba(0, 0, 0, 0.38);
}

.lamp::before,
.slot-button::before {
  content: "";
  position: absolute;
  inset: 9% 10% 30%;
  border-radius: 3px;
  background: var(--slot-dark);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.04),
    inset 0 -4px 8px rgba(0, 0, 0, 0.42);
}

.lamp::after,
.slot-button::after {
  content: "";
  position: absolute;
  left: 14%;
  right: 14%;
  bottom: 11%;
  height: 12%;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.18);
}

.lamp--lit::before,
.slot-button--filled::before {
  background:
    radial-gradient(circle at 38% 30%, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 22%),
    var(--lamp-color);
  box-shadow:
    0 0 14px color-mix(in srgb, var(--lamp-color), white 18%),
    inset 0 0 8px rgba(255, 255, 255, 0.2),
    inset 0 -8px 10px rgba(0, 0, 0, 0.22);
}

.slot-button {
  cursor: pointer;
  touch-action: manipulation;
}

.slot-button:disabled {
  cursor: default;
}

.guess-row--current .slot-button {
  box-shadow:
    0 0 0 2px rgba(203, 231, 93, 0.22),
    inset 0 3px 0 rgba(255, 255, 255, 0.08),
    inset 0 -5px 0 rgba(0, 0, 0, 0.28),
    0 5px 0 rgba(0, 0, 0, 0.38);
}

.guess-row--current .slot-button--selected {
  box-shadow:
    0 0 0 3px rgba(255, 228, 92, 0.92),
    0 0 18px rgba(255, 228, 92, 0.35),
    inset 0 3px 0 rgba(255, 255, 255, 0.08),
    inset 0 -5px 0 rgba(0, 0, 0, 0.28),
    0 5px 0 rgba(0, 0, 0, 0.38);
}

.guess-row--locked .slot-button {
  pointer-events: none;
}

.feedback-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: repeat(7, minmax(0, 1fr));
  gap: clamp(7px, 1.5svh, 10px);
  padding: clamp(8px, 2.2vw, 12px) clamp(7px, 2vw, 10px);
  border-radius: 8px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0)),
    #101112;
  box-shadow: inset 8px 0 12px rgba(0, 0, 0, 0.35);
}

.feedback-row {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(10px, 1fr));
  grid-template-rows: repeat(2, minmax(10px, 1fr));
  gap: clamp(5px, 1.2vw, 8px);
  align-content: center;
}

.pip {
  width: min(100%, 16px);
  aspect-ratio: 1;
  place-self: center;
  border-radius: 50%;
  background: #2c3030;
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.08),
    inset 0 -2px 3px rgba(0, 0, 0, 0.56);
}

.pip--exact {
  background: var(--green);
  box-shadow:
    0 0 8px rgba(99, 255, 79, 0.82),
    inset 0 0 3px rgba(255, 255, 255, 0.65);
}

.pip--color {
  background: var(--white);
  box-shadow:
    0 0 5px rgba(255, 255, 255, 0.4),
    inset 0 -2px 3px rgba(0, 0, 0, 0.22);
}

.control-panel {
  display: grid;
  gap: clamp(7px, 1.5svh, 10px);
  padding-top: 6px;
}

.answer-strip {
  display: none;
  grid-template-columns: auto repeat(4, 34px);
  align-items: center;
  justify-content: center;
  gap: clamp(7px, 2vw, 10px);
  min-height: 46px;
  padding: 7px 10px;
  border-radius: 5px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0)),
    #202326;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.07),
    0 4px 0 rgba(0, 0, 0, 0.2);
}

.answer-strip--visible {
  display: grid;
}

.answer-strip__label {
  color: #f1f4ec;
  font-size: 0.84rem;
  font-weight: 950;
  white-space: nowrap;
}

.answer-strip .lamp {
  width: 34px;
}

.brand-rail {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: clamp(8px, 2.2vw, 14px);
  min-height: 42px;
  padding: 6px 10px;
  border-radius: 4px;
  background: #202326;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 4px 0 rgba(0, 0, 0, 0.2);
}

.color-rail {
  min-height: 30px;
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: clamp(5px, 1.6vw, 9px);
  align-items: center;
}

.brand-name {
  color: #f1f4ec;
  font-size: clamp(0.95rem, 4vw, 1.25rem);
  font-weight: 950;
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
}

.color-button {
  width: min(100%, 26px);
  aspect-ratio: 1;
  justify-self: center;
  border: 0;
  border-radius: 4px;
  background:
    radial-gradient(circle at 38% 28%, rgba(255, 255, 255, 0.85), rgba(255, 255, 255, 0) 26%),
    var(--lamp-color);
  box-shadow:
    0 0 7px color-mix(in srgb, var(--lamp-color), white 16%),
    inset 0 -4px 7px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  touch-action: manipulation;
}

.lower-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto clamp(72px, 22vw, 94px);
  gap: clamp(8px, 2.2vw, 12px);
  align-items: stretch;
}

.display-wrap {
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(52px, 1fr) auto;
  padding: 8px;
  border-radius: 4px;
  background: var(--screen);
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.05),
    inset 0 -7px 13px rgba(0, 0, 0, 0.28);
}

.display {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--segment);
  font-family: "Courier New", ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: clamp(2.05rem, 10.6vw, 3.4rem);
  font-weight: 900;
  line-height: 0.9;
  letter-spacing: 0;
  text-shadow:
    0 2px 0 #ffffff,
    0 0 12px rgba(255, 255, 255, 0.32);
}

.status-text {
  min-height: 1.2em;
  overflow: hidden;
  color: #c7d2d4;
  font-size: 0.75rem;
  font-weight: 800;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.small-controls {
  display: grid;
  grid-template-columns: repeat(2, 42px);
  grid-auto-rows: 38px;
  gap: 7px;
}

.mini-button {
  border: 0;
  border-radius: 5px;
  color: #f3f5f6;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0)),
    #2d3134;
  box-shadow:
    inset 0 -3px 0 rgba(0, 0, 0, 0.28),
    0 3px 0 rgba(0, 0, 0, 0.22);
  font-size: 1.05rem;
  font-weight: 900;
  cursor: pointer;
}

.knob {
  position: relative;
  align-self: stretch;
  min-height: 88px;
  border: 0;
  border-radius: 50%;
  color: #481c06;
  background:
    repeating-conic-gradient(
      from 0deg,
      #bf4218 0deg 8deg,
      var(--orange) 8deg 16deg,
      #ff8b3a 16deg 22deg
    );
  box-shadow:
    inset 8px 10px 18px rgba(255, 255, 255, 0.22),
    inset -8px -10px 18px rgba(83, 24, 5, 0.34),
    0 8px 0 #8c3518,
    0 15px 20px rgba(0, 0, 0, 0.22);
  cursor: pointer;
  touch-action: manipulation;
}

.knob::before {
  content: "";
  position: absolute;
  inset: 16%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 38% 30%, rgba(255, 255, 255, 0.3), transparent 30%),
    #e96527;
  box-shadow: inset 0 -8px 15px rgba(92, 28, 7, 0.28);
}

.knob span {
  position: relative;
  z-index: 1;
  font-weight: 950;
  letter-spacing: 0;
}

.mini-button:disabled,
.knob:disabled,
.color-button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.55);
  opacity: 0.55;
}

.slot-button:active,
.color-button:active,
.mini-button:active,
.knob:active,
.time-button:active,
.modal-button:active {
  transform: translateY(1px) scale(0.98);
}

.slot-button:focus-visible,
.color-button:focus-visible,
.mini-button:focus-visible,
.knob:focus-visible,
.time-button:focus-visible,
.modal-button:focus-visible {
  outline: 3px solid rgba(255, 255, 255, 0.86);
  outline-offset: 3px;
}

.modal {
  width: min(calc(100vw - 28px), 390px);
  padding: 0;
  border: 0;
  border-radius: 14px;
  background: transparent;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.62);
  backdrop-filter: blur(3px);
}

.modal__body {
  padding: 18px;
  border-radius: 14px;
  background: #f7f8f4;
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.32);
}

.modal__kicker {
  margin: 0 0 6px;
  color: var(--case-dark);
  font-size: 0.72rem;
  font-weight: 900;
}

.modal h2 {
  margin: 0 0 8px;
  font-size: 1.5rem;
  letter-spacing: 0;
}

.modal p {
  margin: 0 0 12px;
  color: #4b5353;
  line-height: 1.55;
}

.time-options {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0 16px;
}

.time-button {
  min-width: 0;
  min-height: 46px;
  border: 0;
  border-radius: 7px;
  color: #f4f6ef;
  background: #2d3235;
  box-shadow:
    inset 0 -3px 0 rgba(0, 0, 0, 0.3),
    inset 0 0 0 1px rgba(255, 255, 255, 0.07);
  font-weight: 900;
  cursor: pointer;
}

.time-button--selected {
  color: #1b220f;
  background: var(--case);
  box-shadow:
    0 0 0 2px rgba(54, 69, 22, 0.25),
    inset 0 -3px 0 rgba(42, 58, 18, 0.18);
}

.reveal {
  display: grid;
  grid-template-columns: repeat(4, 42px);
  gap: 9px;
  margin: 14px 0 18px;
}

.reveal .lamp {
  width: 42px;
}

.modal__actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.modal__actions--single {
  grid-template-columns: 1fr;
}

.modal-button {
  min-height: 44px;
  border: 0;
  border-radius: 7px;
  color: var(--ink);
  background: #e2e6df;
  font-weight: 900;
  cursor: pointer;
}

.modal-button--primary {
  background: var(--case);
}

@media (max-width: 380px) {
  .machine {
    padding: 14px;
  }

  .face {
    grid-template-columns: minmax(0, 1fr) 54px;
    padding: 9px;
  }

  .guess-row {
    gap: 7px;
  }

  .feedback-panel {
    padding-inline: 6px;
  }

  .lower-row {
    grid-template-columns: minmax(0, 1fr) auto 72px;
  }

  .small-controls {
    grid-template-columns: repeat(2, 36px);
    grid-auto-rows: 34px;
    gap: 6px;
  }

  .knob {
    min-height: 76px;
  }
}

@media (max-height: 690px) {
  .decoder {
    min-height: 0;
  }

  .display {
    font-size: 2.35rem;
  }

  .knob {
    min-height: 70px;
  }
}
