:root {
  --blue-950: #063b8f;
  --blue-800: #075fc9;
  --blue-650: #0b73e8;
  --blue-100: #dff0ff;
  --yellow: #ffd43b;
  --yellow-dark: #f2a900;
  --white: #ffffff;
  --ink: #13213a;
  --muted: #586579;
  --danger: #c42b45;
  --shadow: 0 18px 42px rgba(3, 33, 91, 0.25);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--blue-800);
}

body {
  min-height: 100dvh;
  margin: 0;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 212, 59, 0.34), transparent 32rem),
    linear-gradient(150deg, var(--blue-650), var(--blue-950));
}

button,
select,
textarea {
  font: inherit;
}

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

.app-shell {
  min-height: 100dvh;
  padding: max(18px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
  display: grid;
}

.screen {
  display: none;
  width: min(720px, 100%);
  min-height: calc(100dvh - 38px);
  margin: 0 auto;
}

.screen.is-active {
  display: flex;
  flex-direction: column;
}

.title-screen {
  justify-content: center;
  gap: 32px;
}

.title-stack {
  color: var(--white);
  text-align: center;
  text-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
}

.eyebrow {
  display: inline-flex;
  margin: 0 0 12px;
  padding: 8px 14px;
  border: 2px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  color: var(--blue-950);
  background: var(--yellow);
  font-weight: 800;
  font-size: 0.9rem;
  text-shadow: none;
}

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

h1 {
  margin-bottom: 6px;
  font-size: clamp(3.1rem, 14vw, 6.4rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.subtitle {
  margin-bottom: 0;
  color: var(--blue-100);
  font-size: clamp(1.35rem, 5vw, 2rem);
  font-weight: 800;
}

.main-actions,
.panel-form,
.mode-grid {
  display: grid;
  gap: 14px;
}

.primary-button,
.secondary-button,
.bottom-button,
.back-button,
.mode-card {
  min-height: 54px;
  border: 0;
  border-radius: 18px;
  cursor: pointer;
  font-weight: 850;
}

.primary-button {
  padding: 16px 20px;
  color: var(--white);
  background: linear-gradient(180deg, #1593ff, #075fc9);
  box-shadow: 0 12px 0 #054ca3, var(--shadow);
}

.primary-button.accent {
  color: #3b2800;
  background: linear-gradient(180deg, #ffe76a, var(--yellow));
  box-shadow: 0 12px 0 var(--yellow-dark), var(--shadow);
}

.secondary-button,
.bottom-button,
.back-button {
  color: var(--blue-950);
  background: var(--white);
  box-shadow: 0 8px 0 rgba(6, 59, 143, 0.24);
}

.primary-button:active,
.secondary-button:active,
.bottom-button:active,
.back-button:active,
.mode-card:active {
  transform: translateY(5px);
  box-shadow: 0 4px 0 rgba(6, 59, 143, 0.25);
}

.screen-header {
  display: grid;
  grid-template-columns: 88px 1fr 88px;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  color: var(--white);
}

.screen-header h2 {
  margin: 0;
  text-align: center;
  font-size: clamp(1.45rem, 6vw, 2.25rem);
}

.back-button {
  min-height: 44px;
  border-radius: 14px;
}

.mode-card,
.panel-form,
.rules-card,
.guidance-card {
  border-radius: 26px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.mode-card {
  width: 100%;
  padding: 26px 22px;
  display: grid;
  gap: 8px;
  text-align: left;
}

.mode-title {
  color: var(--blue-950);
  font-size: 1.55rem;
  font-weight: 900;
}

.mode-description,
.status-text {
  color: var(--muted);
  font-weight: 700;
}

.panel-form {
  padding: 22px;
}

.field-label {
  color: var(--blue-950);
  font-size: 1.05rem;
  font-weight: 900;
}

select,
textarea {
  width: 100%;
  border: 3px solid #b7d9ff;
  border-radius: 18px;
  color: var(--ink);
  background: #f8fbff;
  font-size: 1.05rem;
}

select {
  min-height: 56px;
  padding: 0 14px;
}

textarea {
  min-height: 170px;
  padding: 14px;
  resize: vertical;
  line-height: 1.55;
}

select:focus,
textarea:focus,
button:focus-visible {
  outline: 4px solid rgba(255, 212, 59, 0.72);
  outline-offset: 3px;
}

.status-text,
.error-text {
  margin: 0;
  line-height: 1.6;
}

.error-text {
  color: var(--danger);
  font-weight: 850;
}

.guidance-screen {
  justify-content: center;
}

.guidance-card {
  padding: 30px 22px;
  display: grid;
  gap: 18px;
  text-align: center;
}

.guidance-card p {
  margin: 0;
  color: var(--blue-950);
  font-size: clamp(1.35rem, 6vw, 2.15rem);
  font-weight: 900;
  line-height: 1.35;
}

.countdown {
  margin: 4px auto 0;
  width: clamp(108px, 34vw, 160px);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 8px solid var(--yellow);
  border-radius: 50%;
  color: var(--blue-950);
  background: var(--blue-100);
  font-size: clamp(4rem, 18vw, 7rem);
  font-weight: 950;
}

.display-screen {
  width: min(1040px, 100%);
  justify-content: center;
  gap: 18px;
}

.display-card {
  min-height: min(62dvh, 560px);
  padding: clamp(18px, 5vw, 44px);
  display: grid;
  grid-template-rows: auto 1fr;
  align-items: center;
  border: 8px solid var(--yellow);
  border-radius: 30px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.display-label {
  margin: 0;
  color: var(--muted);
  text-align: center;
  font-weight: 900;
}

.display-text {
  max-height: 100%;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--blue-950);
  text-align: center;
  font-size: clamp(2.3rem, 11vw, 7rem);
  font-weight: 950;
  line-height: 1.12;
}

.bottom-button {
  width: min(360px, 100%);
  margin: 0 auto;
  padding: 15px 18px;
}

.rules-card {
  padding: 24px 20px;
  display: grid;
  gap: 14px;
  font-size: clamp(1.05rem, 4.2vw, 1.35rem);
  font-weight: 800;
  line-height: 1.65;
}

.rules-card p {
  margin: 0;
}

@media (orientation: landscape) and (max-height: 520px) {
  .app-shell {
    padding: 12px max(18px, env(safe-area-inset-right)) 12px max(18px, env(safe-area-inset-left));
  }

  .screen {
    min-height: calc(100dvh - 24px);
  }

  .title-screen {
    justify-content: center;
    grid-template-columns: 1fr 1fr;
  }

  .display-screen {
    gap: 12px;
  }

  .display-card {
    min-height: 68dvh;
  }

  .display-text {
    font-size: clamp(2.2rem, 9vw, 5.8rem);
  }
}

@media (min-width: 680px) {
  .mode-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .panel-form,
  .rules-card,
  .guidance-card {
    padding: 30px;
  }
}
