:root {
  color-scheme: light;
  --ink: #332d2a;
  --muted: #716760;
  --paper: #f7f1e8;
  --paper-deep: #ede2d3;
  --line: rgba(89, 72, 58, 0.18);
  --shadow: rgba(70, 48, 34, 0.18);
  --glass: rgba(255, 255, 255, 0.58);
  --accent: #7e9b73;
  --accent-strong: #506b46;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at 15% 0%, rgba(238, 196, 197, 0.34), transparent 32rem),
    linear-gradient(145deg, #f8f1e7 0%, #eee5d7 48%, #f5eee4 100%);
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family:
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  overflow-x: hidden;
}

button {
  min-height: 36px;
  border: 1px solid rgba(83, 69, 55, 0.18);
  border-radius: 7px;
  background: rgba(255, 252, 245, 0.78);
  color: var(--ink);
  font: inherit;
  font-size: 0.76rem;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(76, 55, 39, 0.08);
  touch-action: manipulation;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

button:focus-visible,
.cup-button:focus-visible {
  outline: 3px solid rgba(80, 107, 70, 0.38);
  outline-offset: 3px;
}

.app-shell {
  width: min(1120px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px clamp(12px, 4vw, 30px) 26px;
}

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  padding-right: 46px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
  white-space: nowrap;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.42rem, 4.8vw, 2.45rem);
  line-height: 1;
  font-weight: 850;
}

.status-strip {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.status-pill {
  min-width: 64px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.64);
  text-align: center;
}

.status-pill span {
  display: block;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 700;
}

.status-pill strong {
  display: block;
  margin-top: 2px;
  font-size: 1.12rem;
  line-height: 1;
}

.control-bar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
  margin: 12px 0 8px;
}

.icon-button {
  font-size: 0.76rem;
  line-height: 1;
}

.language-toggle {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 34px;
  min-height: 28px;
  padding: 0 6px;
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  box-shadow: none;
  font-size: 0.72rem;
  font-weight: 900;
}

.message-line {
  display: none;
  min-height: 0;
  color: var(--muted);
  font-weight: 700;
}

.board {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(82px, 1fr));
  gap: clamp(12px, 3vw, 22px);
  align-items: end;
  padding: 14px 0 26px;
}

.cup-button {
  position: relative;
  display: grid;
  place-items: end center;
  min-height: 184px;
  padding: 16px 6px 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  box-shadow: none;
  touch-action: manipulation;
}

.cup-button.selected .cup {
  transform: translateY(-12px);
  box-shadow: 0 20px 28px rgba(70, 48, 34, 0.19);
}

.cup {
  position: relative;
  width: min(86px, 100%);
  height: clamp(152px, calc(104px + var(--capacity) * 12px), 224px);
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
  overflow: hidden;
  border: 3px solid rgba(98, 84, 72, 0.28);
  border-top-color: rgba(98, 84, 72, 0.38);
  border-radius: 10px 10px 24px 24px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.52), transparent 24%, transparent 74%, rgba(255, 255, 255, 0.3)),
    rgba(255, 255, 255, 0.35);
  box-shadow: 0 14px 24px rgba(70, 48, 34, 0.12);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease;
}

.cup::before {
  content: "";
  position: absolute;
  inset: 8px 13px auto auto;
  width: 12px;
  height: 78%;
  border-radius: 999px;
  background: linear-gradient(rgba(255, 255, 255, 0.45), transparent);
  pointer-events: none;
  z-index: 4;
}

.cup::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 -14px 18px rgba(84, 61, 45, 0.08);
  pointer-events: none;
  z-index: 5;
}

.layer {
  position: relative;
  flex: 0 0 calc(100% / var(--capacity));
  background:
    linear-gradient(180deg, var(--top), var(--bottom));
}

.layer.hidden {
  display: grid;
  place-items: center;
  color: rgba(75, 63, 54, 0.72);
  font-weight: 900;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.24) 0 6px, transparent 6px 13px),
    linear-gradient(180deg, #d8d0c6, #beb5aa);
}

.layer.hidden::after {
  content: "?";
}

.cup-label {
  margin-top: 8px;
  min-height: 19px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: center;
}

.win-dialog {
  width: min(92vw, 390px);
  border: 0;
  border-radius: 12px;
  padding: 0;
  background: transparent;
}

.win-dialog::backdrop {
  background: rgba(43, 34, 28, 0.32);
  backdrop-filter: blur(2px);
}

.dialog-panel {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fffaf1;
  box-shadow: 0 24px 60px rgba(45, 32, 24, 0.28);
}

.dialog-panel h2 {
  font-size: 1.7rem;
}

.dialog-panel p:not(.eyebrow) {
  color: var(--muted);
  font-weight: 700;
}

.dialog-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 18px;
}

.primary {
  background: var(--accent);
  color: #fffdf6;
}

@media (max-width: 620px) {
  .topbar {
    align-items: center;
    flex-direction: row;
    gap: 10px;
  }

  .status-strip {
    width: auto;
    justify-content: flex-end;
    flex-wrap: nowrap;
  }

  .status-pill {
    flex: 0 0 auto;
  }

  .control-bar {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .board {
    grid-template-columns: repeat(auto-fit, minmax(74px, 1fr));
  }

  .cup-button {
    min-height: clamp(168px, calc(120px + var(--capacity) * 12px), 240px);
  }

  .cup {
    height: clamp(138px, calc(94px + var(--capacity) * 12px), 214px);
  }
}
