:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #41291e;
  --muted: #806557;
  --cream: #fff9e9;
  --paper: #fffdf5;
  --orange: #f7a62f;
  --orange-deep: #d66b18;
  --green: #3c9b57;
  --green-deep: #23733c;
  --line: rgba(95, 57, 33, 0.12);
  --shadow: 0 18px 50px rgba(102, 55, 15, 0.14);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  min-height: 100%;
  background: #f7b84b;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% -10%, rgba(255, 255, 255, 0.72), transparent 32%),
    linear-gradient(155deg, #ffd879 0%, #f5aa35 38%, #f4e9ca 38%, #f8f2df 100%);
  overscroll-behavior: none;
}

button {
  color: inherit;
  font: inherit;
}

button:focus-visible {
  outline: 3px solid rgba(35, 115, 60, 0.42);
  outline-offset: 3px;
}

.app-shell {
  width: min(100%, 560px);
  min-height: 100vh;
  min-height: 100svh;
  margin: 0 auto;
  padding: max(14px, env(safe-area-inset-top)) 14px max(22px, env(safe-area-inset-bottom));
}

.topbar,
.status-card,
.tray-heading,
.footer-bar,
.brand,
.balance,
.booster {
  display: flex;
  align-items: center;
}

.topbar {
  justify-content: space-between;
  padding: 4px 2px 14px;
}

.brand {
  gap: 10px;
}

.brand-mark {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 2px solid rgba(70, 42, 20, 0.14);
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(145deg, #4aa966, #24713e);
  box-shadow: 0 7px 18px rgba(35, 115, 60, 0.25);
  font-size: 21px;
  font-weight: 900;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 20px;
  letter-spacing: -0.03em;
}

.brand small {
  margin-top: 1px;
  color: rgba(65, 41, 30, 0.62);
  font-size: 11px;
}

.balance {
  min-height: 42px;
  gap: 6px;
  padding: 6px 10px 6px 8px;
  border: 1px solid rgba(84, 51, 22, 0.12);
  border-radius: 16px;
  background: rgba(255, 253, 245, 0.82);
  box-shadow: 0 7px 18px rgba(103, 55, 14, 0.11);
  cursor: pointer;
}

.balance span {
  font-size: 20px;
}

.balance strong {
  font-size: 17px;
}

.balance small {
  color: var(--muted);
  font-size: 10px;
}

.status-card {
  position: relative;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 12px;
  padding: 17px 18px 15px;
  border: 1px solid rgba(115, 65, 25, 0.1);
  border-radius: 24px 24px 18px 18px;
  background: rgba(255, 251, 235, 0.92);
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--green-deep);
  font-size: 10px;
  font-weight: 850;
  letter-spacing: 0.13em;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(19px, 5.2vw, 25px);
  letter-spacing: -0.04em;
}

.icon-button {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--green-deep);
  background: #edf8e9;
  font-weight: 900;
  cursor: pointer;
}

.progress-row {
  display: grid;
  width: 100%;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
}

.progress-track {
  height: 9px;
  overflow: hidden;
  border-radius: 99px;
  background: #eadfc7;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #6ecf56, #27924c);
  transition: width 280ms ease;
}

.progress-row strong {
  min-width: 36px;
  color: var(--green-deep);
  font-size: 12px;
  text-align: right;
}

.game-card {
  margin-top: 10px;
  overflow: hidden;
  padding: 14px 12px 15px;
  border: 1px solid rgba(95, 57, 33, 0.1);
  border-radius: 18px 18px 28px 28px;
  background:
    linear-gradient(rgba(255, 255, 255, 0.36), rgba(255, 255, 255, 0.08)),
    #f7edcf;
  box-shadow: var(--shadow);
}

.board-wrap {
  position: relative;
}

.board-glow {
  position: absolute;
  inset: 13% 12% 8%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 193, 61, 0.32), transparent 68%);
  filter: blur(10px);
}

.board {
  position: relative;
  width: 100%;
  aspect-ratio: 1.08 / 1;
  min-height: 302px;
  isolation: isolate;
}

.tile {
  position: absolute;
  z-index: var(--tile-z);
  left: var(--tile-x);
  top: var(--tile-y);
  display: grid;
  width: 16.4%;
  aspect-ratio: 0.84;
  place-content: center;
  justify-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid rgba(101, 58, 30, 0.18);
  border-bottom-width: 4px;
  border-radius: 13px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.9), rgba(255, 246, 215, 0.92)),
    #fff9df;
  box-shadow: 0 6px 10px rgba(92, 54, 25, 0.16);
  transform: translateY(0) scale(1);
  transition: transform 130ms ease, filter 130ms ease, opacity 130ms ease, box-shadow 130ms ease;
}

.tile > span {
  font-size: clamp(23px, 7vw, 35px);
  line-height: 1;
  filter: saturate(0.95);
}

.tile small {
  max-width: 100%;
  overflow: hidden;
  color: #755140;
  font-size: clamp(7px, 1.8vw, 9px);
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile.is-exposed {
  cursor: pointer;
}

.tile.is-exposed:active {
  transform: translateY(3px) scale(0.96);
  box-shadow: 0 2px 4px rgba(92, 54, 25, 0.16);
}

.tile.is-blocked {
  filter: brightness(0.72) saturate(0.74);
  opacity: 0.83;
}

.tile.is-hinted {
  z-index: 999;
  box-shadow: 0 0 0 4px #fff, 0 0 0 8px #51ba63, 0 10px 24px rgba(42, 142, 70, 0.38);
  animation: hintPulse 720ms ease-in-out infinite alternate;
}

@keyframes hintPulse {
  to { transform: translateY(-5px) scale(1.04); }
}

.board-caption {
  min-height: 18px;
  margin: -4px 0 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 650;
  text-align: center;
}

.tray-panel {
  padding: 11px;
  border: 1px solid rgba(99, 57, 27, 0.11);
  border-radius: 18px;
  background: rgba(255, 253, 246, 0.88);
}

.tray-heading {
  justify-content: space-between;
  margin: 0 2px 8px;
}

.tray-heading > span {
  font-size: 12px;
  font-weight: 850;
}

.tray-heading small {
  color: var(--muted);
  font-size: 10px;
}

.tray {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 5px;
  padding: 6px;
  border-radius: 14px;
  background: #e9d7b9;
  box-shadow: inset 0 2px 5px rgba(82, 48, 26, 0.14);
  transition: background 160ms ease;
}

.tray.is-danger {
  background: #eaa68f;
}

.tray-slot {
  display: grid;
  aspect-ratio: 0.82;
  place-items: center;
  border: 1px dashed rgba(90, 55, 35, 0.16);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.31);
}

.tray-slot.is-filled {
  border-style: solid;
  background: #fff9e6;
  box-shadow: 0 3px 6px rgba(85, 48, 22, 0.13);
  animation: trayIn 170ms ease-out;
}

.tray-slot span {
  font-size: clamp(20px, 6vw, 29px);
}

@keyframes trayIn {
  from { transform: translateY(-12px) scale(0.84); opacity: 0; }
}

.boosters {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 7px;
  margin-top: 10px;
}

.booster {
  min-width: 0;
  min-height: 58px;
  gap: 7px;
  justify-content: center;
  padding: 7px 5px;
  border: 1px solid rgba(85, 51, 29, 0.11);
  border-radius: 15px;
  background: rgba(255, 253, 246, 0.86);
  cursor: pointer;
}

.booster:disabled {
  cursor: default;
  filter: grayscale(0.7);
  opacity: 0.46;
}

.booster-icon {
  display: grid;
  width: 29px;
  height: 29px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 10px;
  background: #e9f6df;
  font-size: 16px;
  font-weight: 900;
}

.booster strong,
.booster small {
  display: block;
  min-width: 0;
  text-align: left;
}

.booster strong {
  overflow: hidden;
  font-size: clamp(9px, 2.8vw, 12px);
  text-overflow: ellipsis;
}

.booster small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 8px;
}

.honesty-note {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 12px 2px 0;
  padding: 12px 14px;
  border: 1px solid rgba(45, 133, 65, 0.16);
  border-radius: 16px;
  background: rgba(229, 246, 218, 0.76);
}

.honesty-note > span {
  display: grid;
  width: 23px;
  height: 23px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  color: white;
  background: var(--green);
  font-size: 12px;
  font-weight: 900;
}

.honesty-note p {
  margin: 1px 0 0;
  color: #45613c;
  font-size: 10px;
  line-height: 1.45;
}

.footer-bar {
  justify-content: space-between;
  gap: 14px;
  padding: 14px 4px 0;
  color: rgba(65, 41, 30, 0.58);
  font-size: 9px;
}

.footer-bar button,
.text-button {
  padding: 0;
  border: 0;
  color: var(--green-deep);
  background: transparent;
  font-size: 10px;
  font-weight: 800;
  cursor: pointer;
}

.modal-backdrop {
  position: fixed;
  z-index: 2000;
  inset: 0;
  display: grid;
  place-items: end center;
  padding: 16px;
  background: rgba(52, 31, 19, 0.46);
  opacity: 0;
  backdrop-filter: blur(8px);
  transition: opacity 180ms ease;
}

.modal-backdrop[hidden] {
  display: none;
}

.modal-backdrop.is-visible {
  opacity: 1;
}

.modal {
  width: min(100%, 520px);
  padding: 26px 22px max(22px, env(safe-area-inset-bottom));
  border: 1px solid rgba(100, 57, 26, 0.12);
  border-radius: 28px;
  background: var(--paper);
  box-shadow: 0 25px 70px rgba(50, 27, 13, 0.3);
  transform: translateY(24px);
  transition: transform 180ms ease;
}

.modal-backdrop.is-visible .modal {
  transform: translateY(0);
}

.modal-mascot {
  display: grid;
  width: 58px;
  height: 58px;
  margin-bottom: 14px;
  place-items: center;
  border-radius: 19px;
  background: linear-gradient(145deg, #fff1b8, #ffd36e);
  box-shadow: 0 8px 20px rgba(152, 91, 20, 0.18);
  font-size: 31px;
}

.modal h2 {
  margin-bottom: 12px;
  font-size: 25px;
  letter-spacing: -0.04em;
}

.modal-body {
  color: #6d5245;
  font-size: 13px;
  line-height: 1.55;
}

.modal-body ol {
  margin: 0 0 14px;
  padding-left: 21px;
}

.modal-body li + li {
  margin-top: 7px;
}

.modal-fineprint {
  padding: 10px 12px;
  border-radius: 12px;
  color: #396344;
  background: #edf7e7;
  font-size: 11px;
}

.primary-button {
  width: 100%;
  min-height: 52px;
  margin-top: 5px;
  border: 0;
  border-radius: 17px;
  color: white;
  background: linear-gradient(180deg, #58bd56, #278e47);
  box-shadow: 0 8px 0 #1e6836, 0 14px 25px rgba(36, 123, 61, 0.23);
  font-weight: 850;
  cursor: pointer;
}

.primary-button:active {
  transform: translateY(5px);
  box-shadow: 0 3px 0 #1e6836;
}

.text-button {
  display: block;
  margin: 18px auto 0;
}

.toast {
  position: fixed;
  z-index: 3000;
  left: 50%;
  bottom: max(20px, env(safe-area-inset-bottom));
  width: max-content;
  max-width: calc(100% - 32px);
  padding: 11px 15px;
  border-radius: 99px;
  color: white;
  background: rgba(56, 38, 29, 0.92);
  box-shadow: 0 10px 28px rgba(40, 25, 17, 0.22);
  font-size: 11px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 15px);
  transition: opacity 180ms ease, transform 180ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

@media (min-width: 620px) {
  .app-shell {
    padding-top: 28px;
    padding-bottom: 38px;
  }

  .board {
    min-height: 430px;
  }

  .modal-backdrop {
    place-items: center;
  }
}

@media (max-width: 360px) {
  .app-shell {
    padding-inline: 9px;
  }

  .board {
    min-height: 285px;
  }

  .tile small {
    display: none;
  }

  .booster {
    gap: 4px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

