:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #f8fafc;
  background: #0b1020;
  --panel-2: rgba(30, 41, 59, .94);
  --border: rgba(255, 255, 255, .10);
  --muted: #94a3b8;
  --accent: #fbbf24;
  --accent-2: #f59e0b;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #0b1020;
}

body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 20% 0%, rgba(251,191,36,.13), transparent 34%),
    radial-gradient(circle at 100% 20%, rgba(59,130,246,.12), transparent 30%),
    linear-gradient(180deg, #0b1020 0%, #111827 100%);
}

button { font: inherit; }

.app-shell {
  width: 100%;
  max-width: 760px;
  height: 100dvh;
  min-height: 0;
  min-width: 0;
  margin: 0 auto;
  padding:
    max(12px, env(safe-area-inset-top))
    max(16px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(16px, env(safe-area-inset-left));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 8px;
  overflow: hidden;
}

.topbar,
.game-area,
.card-zone,
.bottom-action,
.brand,
.brand-copy,
.phrase-card { min-width: 0; }

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

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.brand-icon {
  flex: 0 0 auto;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  box-shadow: 0 12px 30px rgba(245,158,11,.22);
  font-size: 24px;
}

.brand-copy { overflow: hidden; }
.brand h1 {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.05;
  letter-spacing: -.02em;
  white-space: nowrap;
}
.brand p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: .72rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.mode-switch {
  flex: 0 0 auto;
  border: 1px solid var(--border);
  color: #fff;
  border-radius: 999px;
  min-width: 96px;
  height: 42px;
  padding: 0 14px;
  font-weight: 950;
  font-size: .76rem;
  letter-spacing: .05em;
  cursor: pointer;
  transition: .18s ease;
  box-shadow: 0 10px 30px rgba(0,0,0,.18);
}
.mode-normal { background: linear-gradient(135deg, #334155, #1e293b); }
.mode-kids { background: linear-gradient(135deg, #22c55e, #16a34a); }
.mode-adult { background: linear-gradient(135deg, #ef4444, #b91c1c); }
.mode-switch:active { transform: scale(.97); }

.game-area {
  width: 100%;
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  overflow: hidden;
}

.current-category {
  align-self: start;
  text-align: center;
  color: #fde68a;
  font-weight: 1000;
  font-size: clamp(1rem, 3.7vw, 1.24rem);
  letter-spacing: .055em;
  text-transform: uppercase;
  line-height: 1.18;
  margin-top: clamp(26px, 5.2vh, 56px);
  padding: 0 8px;
  text-wrap: balance;
}

.card-zone {
  min-height: 0;
  width: 100%;
  display: grid;
  place-items: center;
  padding: clamp(18px, 3.2vh, 34px) 0 clamp(8px, 1.8vh, 18px);
}

.phrase-card {
  width: 100%;
  height: clamp(210px, 40dvh, 330px);
  max-height: 100%;
  border-radius: 28px;
  background:
    linear-gradient(145deg, rgba(255,255,255,.08), rgba(255,255,255,.03)),
    var(--panel-2);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: 0 28px 60px rgba(0,0,0,.26);
  padding: clamp(18px, 5vw, 30px);
  display: grid;
  place-items: center;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.phrase-card::after {
  content: "";
  position: absolute;
  width: 170px;
  height: 170px;
  border-radius: 50%;
  background: rgba(251,191,36,.06);
  right: -55px;
  bottom: -70px;
}

.phrase {
  width: 100%;
  max-width: 100%;
  font-size: clamp(1.85rem, 8vw, 3.25rem);
  line-height: 1.07;
  font-weight: 950;
  letter-spacing: -.043em;
  overflow-wrap: anywhere;
  word-break: normal;
  text-wrap: balance;
  position: relative;
  z-index: 1;
}

.bottom-action {
  width: 100%;
  position: relative;
  z-index: 5;
}

.draw-btn {
  width: 100%;
  min-height: 60px;
  border: 0;
  border-radius: 20px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #111827;
  font-weight: 950;
  letter-spacing: .04em;
  font-size: 1.02rem;
  cursor: pointer;
  box-shadow: 0 16px 36px rgba(245,158,11,.28);
  transition: .15s ease;
}
.draw-btn:active { transform: translateY(1px) scale(.99); }

.card-pop { animation: cardPop .24s ease; }
@keyframes cardPop {
  from { transform: scale(.975); opacity: .65; }
  to { transform: scale(1); opacity: 1; }
}

@media (max-width: 480px) {
  .app-shell {
    padding-top: max(9px, env(safe-area-inset-top));
    padding-right: max(11px, env(safe-area-inset-right));
    padding-bottom: max(9px, env(safe-area-inset-bottom));
    padding-left: max(11px, env(safe-area-inset-left));
    gap: 5px;
  }
  .brand-icon {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    font-size: 21px;
  }
  .brand h1 { font-size: 1.06rem; }
  .brand p { display: none; }
  .mode-switch {
    min-width: 84px;
    height: 38px;
    padding: 0 10px;
    font-size: .69rem;
  }
  .current-category {
    margin-top: clamp(24px, 4.7vh, 42px);
    font-size: clamp(.96rem, 4.5vw, 1.12rem);
  }
  .card-zone { padding: clamp(18px, 3vh, 28px) 0 6px; }
  .phrase-card {
    height: clamp(205px, 40dvh, 300px);
    border-radius: 23px;
    padding: 16px 14px;
  }
  .phrase { font-size: clamp(1.72rem, 9vw, 2.55rem); }
  .draw-btn {
    min-height: 54px;
    border-radius: 17px;
    font-size: .94rem;
  }
}

@media (max-height: 720px) {
  .app-shell { gap: 4px; }
  .brand-icon { width: 38px; height: 38px; font-size: 20px; }
  .brand h1 { font-size: 1rem; }
  .mode-switch { height: 36px; }
  .current-category { margin-top: 18px; font-size: .95rem; }
  .card-zone { padding-top: 12px; }
  .phrase-card { height: clamp(180px, 38dvh, 245px); }
  .phrase { font-size: clamp(1.55rem, 7.8vw, 2.25rem); }
  .draw-btn { min-height: 50px; }
}

.phrase.phrase-long {
  font-size: clamp(1.35rem, 5.8vw, 2.35rem);
  line-height: 1.12;
  letter-spacing: -.025em;
}

.phrase.phrase-xlong {
  font-size: clamp(1.05rem, 4.4vw, 1.8rem);
  line-height: 1.16;
  letter-spacing: -.015em;
}

@media (max-width: 480px) {
  .phrase.phrase-long { font-size: clamp(1.25rem, 6.4vw, 1.85rem); }
  .phrase.phrase-xlong { font-size: clamp(1rem, 5.2vw, 1.45rem); }
}
