:root {
  color-scheme: light;
  --ink: #132030;
  --muted: #5b6675;
  --line: #d7dde4;
  --panel: #f7f9fb;
  --blue: #17324d;
  --blue-soft: #dfeaf4;
  --green: #176b4d;
  --green-soft: #dff3e9;
  --red: #a73a3a;
  --red-soft: #fae4e2;
  --gold: #9a6a11;
  --gold-soft: #fff0cf;
  --shadow: 0 16px 38px rgba(18, 32, 48, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: #eef2f5;
  color: var(--ink);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

button,
select {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 14px;
  min-height: 100%;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  gap: 16px;
}

.topbar-right {
  align-items: flex-end;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.account-bar {
  align-items: center;
  display: flex;
  gap: 8px;
}

.user-chip {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-button {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  cursor: pointer;
  font-weight: 800;
  min-height: 40px;
  padding: 0 14px;
}

.chip-button.ghost {
  background: transparent;
  color: var(--muted);
}

.eyebrow {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0;
  margin: 0 0 4px;
}

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

h1 {
  font-size: 30px;
  line-height: 1.1;
}

h2 {
  font-size: 36px;
  line-height: 1.15;
}

.session-stats {
  align-items: center;
  display: flex;
  gap: 10px;
  white-space: nowrap;
}

.session-stats span {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(18, 32, 48, 0.06);
  color: var(--muted);
  font-size: 15px;
  padding: 10px 12px;
}

.session-stats strong {
  color: var(--ink);
  font-size: 20px;
}

.status-strip {
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 6px 18px rgba(18, 32, 48, 0.06);
  overflow: hidden;
}

.timer-track {
  background: #e8edf1;
  height: 10px;
}

.timer-fill {
  background: linear-gradient(90deg, var(--green), var(--gold));
  height: 100%;
  transform-origin: left center;
  width: 100%;
}

.status-strip p {
  font-size: 18px;
  font-weight: 800;
  margin: 0;
  padding: 12px 16px 14px;
}

.game-board {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 0;
}

.hand-zone,
.phone-card {
  background: white;
  border: 2px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  min-height: 0;
  overflow: hidden;
  position: relative;
}

.hand-zone {
  align-content: center;
  display: grid;
  gap: 22px;
  justify-items: center;
  padding: 28px;
}

.hand-zone.active,
.phone-card.active {
  border-color: var(--blue);
}

.hand-zone.success,
.phone-card.success {
  background: var(--green-soft);
  border-color: var(--green);
}

.hand-zone.miss,
.phone-card.miss {
  background: var(--red-soft);
  border-color: var(--red);
}

.zone-header {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  text-align: center;
}

.zone-header span {
  color: var(--muted);
  font-size: 24px;
  font-weight: 800;
}

.zone-header strong {
  color: var(--blue);
  font-size: clamp(34px, 5vw, 62px);
  line-height: 1;
}

.hint {
  color: var(--muted);
  font-size: clamp(18px, 2.1vw, 24px);
  font-weight: 800;
  margin: 0;
  text-align: center;
}

.gesture-icon {
  aspect-ratio: 1;
  background: var(--blue-soft);
  border: 4px solid var(--blue);
  color: var(--blue);
  display: grid;
  height: min(32vh, 230px);
  place-items: center;
  position: relative;
}

.gesture-icon.large {
  height: min(34vh, 240px);
}

.gesture-icon.open-hand {
  border-radius: 50% 50% 44% 44%;
}

.gesture-icon.open-hand::before {
  content: "";
  background:
    radial-gradient(circle at 10% 20%, currentColor 0 11%, transparent 12%),
    radial-gradient(circle at 32% 7%, currentColor 0 11%, transparent 12%),
    radial-gradient(circle at 55% 6%, currentColor 0 11%, transparent 12%),
    radial-gradient(circle at 78% 17%, currentColor 0 11%, transparent 12%),
    radial-gradient(circle at 92% 42%, currentColor 0 10%, transparent 11%);
  inset: 16px;
  position: absolute;
}

.gesture-icon.fist {
  border-radius: 32% 32% 42% 42%;
}

.gesture-icon.fist::before {
  content: "";
  background:
    radial-gradient(circle at 24% 38%, currentColor 0 16%, transparent 17%),
    radial-gradient(circle at 48% 30%, currentColor 0 17%, transparent 18%),
    radial-gradient(circle at 72% 38%, currentColor 0 16%, transparent 17%),
    radial-gradient(circle at 52% 66%, currentColor 0 28%, transparent 29%);
  inset: 18px;
  position: absolute;
}

.gesture-icon.chop {
  border-radius: 28px;
  transform: rotate(-8deg);
  width: min(17vh, 120px);
}

.gesture-icon.chop::before {
  content: "";
  background: currentColor;
  border-radius: 999px;
  inset: 18px 34%;
  opacity: 0.95;
  position: absolute;
}

.touch-dots {
  inset: 0;
  pointer-events: none;
  position: absolute;
}

.touch-dot {
  background: rgba(23, 50, 77, 0.18);
  border: 3px solid rgba(23, 50, 77, 0.65);
  border-radius: 50%;
  height: 42px;
  position: absolute;
  transform: translate(-50%, -50%);
  width: 42px;
}

.phone-board {
  display: none;
  min-height: 0;
}

body.layout-phone .game-board {
  display: none;
}

body.layout-phone .phone-board {
  display: grid;
}

body.layout-tablet .game-board {
  display: grid;
}

body.layout-tablet .phone-board {
  display: none;
}

.phone-card {
  align-content: center;
  display: grid;
  gap: 20px;
  justify-items: center;
  padding: 28px;
  text-align: center;
}

.controls {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.icon-button,
.primary-button,
.control-group select {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 48px;
}

.icon-button,
.primary-button {
  background: white;
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.icon-button {
  display: grid;
  font-size: 34px;
  line-height: 1;
  place-items: center;
  width: 58px;
}

.primary-button {
  background: var(--blue);
  color: white;
  min-width: 118px;
  padding: 0 18px;
}

.control-group {
  align-items: center;
  background: white;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 8px;
  min-height: 48px;
  padding: 6px 8px 6px 12px;
}

.control-group span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 900;
}

.control-group select {
  background: var(--panel);
  color: var(--ink);
  padding: 0 30px 0 10px;
}

/* Login screen */
.login-screen {
  align-items: center;
  background: #eef2f5;
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  z-index: 20;
}

.login-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 14px;
  justify-items: center;
  max-width: 420px;
  padding: 40px 32px;
  text-align: center;
  width: 100%;
}

.login-mark {
  height: 110px;
  width: 110px;
}

.login-tagline {
  color: var(--blue);
  font-size: 18px;
  font-weight: 800;
  margin: 0;
}

.login-desc {
  color: var(--muted);
  font-size: 15px;
  margin: 0;
}

.google-button {
  align-items: center;
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--ink);
  cursor: pointer;
  display: flex;
  font-size: 17px;
  font-weight: 800;
  gap: 12px;
  justify-content: center;
  margin-top: 8px;
  min-height: 54px;
  width: 100%;
}

.google-g {
  background: conic-gradient(from -45deg, #ea4335 0 25%, #fbbc05 0 50%, #34a853 0 75%, #4285f4 0);
  border-radius: 50%;
  color: white;
  display: grid;
  font-weight: 900;
  height: 26px;
  place-items: center;
  width: 26px;
}

.login-free {
  color: var(--muted);
  font-size: 13px;
  margin: 0;
}

.login-lang {
  margin-top: 6px;
}

/* Records screen */
.records-screen {
  align-items: center;
  background: rgba(18, 32, 48, 0.45);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 24px;
  position: fixed;
  z-index: 20;
}

.records-card {
  background: white;
  border-radius: 16px;
  box-shadow: var(--shadow);
  display: grid;
  gap: 16px;
  grid-template-rows: auto auto 1fr auto;
  max-height: 90vh;
  max-width: 640px;
  padding: 24px;
  width: 100%;
}

.records-header {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.records-header h2 {
  font-size: 24px;
}

.records-summary {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 1fr;
}

.summary-tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  display: grid;
  gap: 4px;
  padding: 14px 16px;
}

.summary-tile strong {
  color: var(--blue);
  font-size: 30px;
}

.summary-tile span {
  color: var(--muted);
  font-size: 14px;
  font-weight: 800;
}

.records-body {
  min-height: 120px;
  overflow: auto;
  position: relative;
}

.records-table {
  border-collapse: collapse;
  width: 100%;
}

.records-table th,
.records-table td {
  border-bottom: 1px solid var(--line);
  font-size: 15px;
  padding: 10px 8px;
  text-align: left;
}

.records-table th {
  color: var(--muted);
  font-size: 13px;
}

.records-empty {
  color: var(--muted);
  padding: 24px 8px;
  text-align: center;
}

.records-lock {
  align-items: center;
  backdrop-filter: blur(4px);
  background: rgba(247, 249, 251, 0.72);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 16px;
  position: absolute;
}

.lock-inner {
  display: grid;
  gap: 10px;
  justify-items: center;
  max-width: 360px;
  text-align: center;
}

.lock-icon {
  font-size: 34px;
}

.lock-inner h3 {
  font-size: 20px;
  margin: 0;
}

.lock-inner p {
  color: var(--muted);
  font-size: 14px;
  margin: 0 0 6px;
}

.records-footer {
  display: flex;
  justify-content: flex-end;
}

.paid-badge {
  background: var(--gold-soft);
  border-radius: 6px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
  margin-left: 6px;
  padding: 2px 6px;
}

body.is-free .records-footer {
  display: none;
}

@media (max-width: 720px), (max-height: 520px) {
  body {
    overflow: auto;
  }

  .app-shell {
    min-height: 100dvh;
  }

  body:not(.layout-tablet) .game-board {
    display: none;
  }

  body:not(.layout-tablet) .phone-board {
    display: grid;
  }

  .topbar {
    align-items: flex-start;
  }

  .session-stats {
    flex-direction: column;
    gap: 6px;
  }

  .session-stats span {
    font-size: 13px;
    padding: 7px 9px;
  }

  h1 {
    font-size: 24px;
  }

  h2 {
    font-size: 34px;
  }

  .status-strip p {
    font-size: 16px;
  }

  .controls {
    justify-content: stretch;
  }

  .primary-button {
    flex: 1;
  }

  .control-group {
    flex: 1 1 150px;
  }
}
