/* TapBrisk Connect Four — tabletop shell + iframe polish */

:root {
  --felt-0: #1a4d56;
  --felt-1: #123840;
  --felt-2: #0c2c33;
  --board: #1f6fba;
  --ink: #1a2430;
  --ink-soft: #3d4b5c;
  --paper: #f3efe6;
  --paper-2: #e7e0d2;
  --line: #d2c8b4;
  --red: #e23d2e;
  --red-deep: #9b1b14;
  --yellow: #f0c419;
  --yellow-deep: #c49000;
  --cta: #e23d2e;
  --cta-hover: #c62828;
  --shadow: 0 18px 40px rgba(8, 24, 28, 0.28), 0 4px 12px rgba(8, 24, 28, 0.16);
  --radius: 18px;
  --font: "Segoe UI", "Avenir Next", "Helvetica Neue", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html,
body {
  height: 100%;
  overflow: hidden;
  margin: 0;
  padding: 0;
  text-align: center;
  color: var(--ink);
  font-family: var(--font);
  background:
    radial-gradient(ellipse at 50% 20%, rgba(255, 255, 255, 0.06), transparent 55%),
    linear-gradient(165deg, var(--felt-0) 0%, var(--felt-1) 48%, var(--felt-2) 100%);
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100%;
  min-height: 100dvh;
}

.header { display: none; }

.playfield {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.5rem 0.5rem 0.75rem;
}

.section {
  margin: 0 auto;
}

.section-canvas {
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}
.section-canvas:focus {
  outline: 2px solid #7ec8ff;
  outline-offset: 3px;
}
.section-canvas:focus:not(:focus-visible) {
  outline: none;
}

/* ── Dialogs ─────────────────────────────────────────── */

.init-screen,
.message-body {
  text-align: left;
  border: 0;
  border-radius: var(--radius);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow);
  padding: 1rem 1.15rem 1.15rem;
  max-width: 26rem;
  width: calc(100% - 1.5rem);
}

.init-screen {
  max-height: min(92dvh, 100%);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  animation: dialog-in 0.22s ease-out;
}

.message-body {
  animation: dialog-in 0.2s ease-out;
}

@keyframes dialog-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: none; }
}

.init-screen::backdrop,
.message-body::backdrop {
  background: rgba(6, 22, 28, 0.55);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.init-hero {
  display: flex;
  gap: 0.55rem;
  margin-bottom: 0.55rem;
}

.init-disc {
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  box-shadow:
    inset 0 -3px 5px rgba(0, 0, 0, 0.25),
    inset 0 3px 5px rgba(255, 255, 255, 0.35),
    0 2px 4px rgba(0, 0, 0, 0.2);
}
.init-disc--red {
  background: radial-gradient(circle at 35% 30%, #ff8a7a, var(--red) 45%, var(--red-deep));
}
.init-disc--yellow {
  background: radial-gradient(circle at 35% 30%, #ffe27a, var(--yellow) 45%, var(--yellow-deep));
}

.init-screen h1 {
  margin: 0 0 0.35rem;
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--ink);
}

.init-screen h2,
.settings-label {
  display: block;
  margin: 0 0 0.45rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.init-screen .howto {
  margin: 0 0 0.9rem;
  font-size: 0.92rem;
  line-height: 1.4;
  color: var(--ink-soft);
}

.game-settings-form {
  display: grid;
  grid-template-columns: 2fr 3fr;
  gap: 0.65rem 0.75rem;
  margin-bottom: 0;
  align-items: center;
}

.game-settings-form-section {
  grid-column: 1 / span 2;
}

.game-settings-mode-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
}

.mode-card {
  display: block;
  cursor: pointer;
  height: 100%;
}

.mode-card input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.mode-card-body {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-height: 4.1rem;
  padding: 0.65rem 0.45rem;
  border-radius: 12px;
  border: 1.5px solid var(--line);
  background: #faf7f0;
  text-align: center;
  transition: border-color 0.15s ease, background 0.15s ease, transform 0.12s ease;
}

.mode-card:hover .mode-card-body {
  border-color: #b7cce0;
  background: #fff;
}

.mode-card input:checked + .mode-card-body {
  border-color: var(--board);
  background: #e8f2fb;
  box-shadow: inset 0 0 0 1px rgba(31, 111, 186, 0.25);
}

.mode-card input:focus-visible + .mode-card-body {
  outline: 2px solid #7ec8ff;
  outline-offset: 2px;
}

.mode-card-title {
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--ink);
}

.mode-card-desc {
  font-size: 0.72rem;
  line-height: 1.25;
  color: var(--ink-soft);
}

.game-settings-player-1-name-label,
.game-settings-player-2-name-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.game-settings-player-1-name-input,
.game-settings-player-2-name-input {
  width: 100%;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 0.45rem 0.65rem;
  font: inherit;
  font-size: 0.9rem;
  background: #fff;
  color: var(--ink);
}

.game-settings-player-1-name-input:focus,
.game-settings-player-2-name-input:focus {
  outline: none;
  border-color: var(--board);
  box-shadow: 0 0 0 3px rgba(31, 111, 186, 0.18);
}

.game-settings-submit,
.message-body-dismiss {
  appearance: none;
  border: 0;
  border-radius: 999px;
  margin-top: 0.35rem;
  padding: 0.7rem 1.25rem;
  font: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: #fff;
  background: linear-gradient(180deg, #f0584a 0%, var(--cta) 55%, var(--cta-hover) 100%);
  box-shadow: 0 4px 0 var(--red-deep), 0 8px 16px rgba(155, 27, 20, 0.25);
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.15s ease;
}

.game-settings-submit {
  grid-column: 1 / span 2;
  justify-self: stretch;
  width: 100%;
}

.game-settings-submit:hover,
.message-body-dismiss:hover {
  filter: brightness(1.04);
}

.game-settings-submit:active,
.message-body-dismiss:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 var(--red-deep), 0 4px 10px rgba(155, 27, 20, 0.2);
}

.message-body-content {
  font-size: 0.95rem;
  line-height: 1.4;
  color: var(--ink-soft);
  margin-bottom: 0.75rem;
}

.message-body-content h1 {
  margin: 0 0 0.4rem;
  font-size: 1.25rem;
  color: var(--ink);
}

.message-form {
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

/* ── Status bar ──────────────────────────────────────── */

.statusbox {
  width: min(100%, 560px);
  margin: 0.65rem auto 0;
  padding: 0.55rem 0.75rem 0.65rem;
  border-radius: 14px;
  background: rgba(243, 239, 230, 0.92);
  border: 1px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
  color: var(--ink);
  backdrop-filter: blur(6px);
}

.statusbox-body,
.statusbox-controls {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.55rem;
  max-width: none;
  margin: 0;
}

.statusbox-body-game,
.statusbox-body-player {
  font-size: 0.86rem;
  font-weight: 650;
}

.statusbox-body-game { color: var(--ink-soft); }
.statusbox-body-player { color: var(--ink); }

.statusbox-controls {
  justify-content: center;
  margin-top: 0.4rem;
}

.statusbox-button,
.statusbox-button-back {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 0.45rem 0.95rem;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--ink);
  background: var(--paper-2);
  box-shadow: none;
  cursor: pointer;
}

.statusbox-button:hover,
.statusbox-button-back:hover {
  background: #d9d0be;
  border: 0;
  box-shadow: none;
}

.statusbox-body-connection,
.statusbox-button-share {
  display: none !important;
}

.hidden { display: none !important; }

@media (max-width: 420px) {
  .game-settings-mode-list {
    grid-template-columns: 1fr;
  }
  .mode-card-body {
    min-height: 0;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    padding: 0.6rem 0.75rem;
    text-align: left;
  }
}

@media (max-height: 640px) {
  .init-screen {
    max-height: 95dvh;
    padding: 0.75rem 0.9rem 0.9rem;
  }
  .init-screen h1 { font-size: 1.3rem; }
  .init-screen .howto { font-size: 0.85rem; margin-bottom: 0.65rem; }
  .playfield { padding: 0.25rem 0.35rem 0.45rem; }
  .statusbox {
    margin-top: 0.45rem;
    padding: 0.4rem 0.55rem 0.5rem;
    font-size: 0.9em;
  }
}
