:root {
  --bg: #101820;
  --panel: rgba(255, 255, 255, 0.08);
  --panel-strong: rgba(255, 255, 255, 0.13);
  --line: rgba(255, 255, 255, 0.16);
  --ink: #f3f7fb;
  --muted: #aab8c5;
  --accent: #37b887;
  --accent-2: #e6b557;
  --danger: #df5f72;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.28);
}

* { box-sizing: border-box; }

html,
body,
.portal-shell,
.game-card,
.admin-choice,
button,
a {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

input,
textarea {
  -webkit-user-select: text;
  user-select: text;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(55, 184, 135, 0.18), transparent 34%),
    linear-gradient(315deg, rgba(230, 181, 87, 0.14), transparent 30%),
    var(--bg);
  font-family: "Segoe UI", system-ui, sans-serif;
}

a { color: inherit; text-decoration: none; }

.portal-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 22px;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 24px;
}

.portal-top {
  min-height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.brand,
.portal-top nav a,
.portal-session,
.portal-session button {
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  font-weight: 900;
  color: #08120f;
}

.brand strong {
  display: block;
  font-size: 20px;
}

.brand small,
p,
.eyebrow,
.admin-card span {
  color: var(--muted);
}

.portal-top nav a {
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  font-weight: 800;
}

.portal-session {
  justify-content: flex-end;
}

.portal-session span,
.portal-session button {
  padding: 0 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  color: var(--ink);
  font-weight: 800;
}

.portal-session button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.auth-panel {
  align-self: center;
  width: min(920px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 0.95fr) minmax(320px, 390px);
  gap: 20px;
  padding: clamp(18px, 3vw, 30px);
  border: 1px solid var(--line);
  border-radius: 28px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.05)),
    rgba(10, 19, 25, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.auth-copy {
  min-height: 360px;
  display: grid;
  align-content: center;
  gap: 14px;
  padding: 8px;
}

.auth-copy h1 {
  font-size: 64px;
  letter-spacing: 0;
}

.auth-copy p {
  margin: 0;
  font-size: 18px;
}

.auth-form,
.admin-password-form {
  display: grid;
  gap: 12px;
}

.auth-form {
  align-self: center;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(5, 12, 18, 0.54);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.auth-form label,
.admin-password-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
}

.auth-form .field span {
  font-size: 13px;
}

.auth-form input,
.admin-password-form input {
  min-height: 52px;
  width: 100%;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: none;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.09);
  font: inherit;
  font-weight: 700;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.auth-form input:focus,
.admin-password-form input:focus {
  border-color: rgba(55, 184, 135, 0.72);
  background: rgba(255, 255, 255, 0.12);
  box-shadow: 0 0 0 4px rgba(55, 184, 135, 0.13);
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.07);
}

.segmented button {
  min-height: 42px;
  border: 0;
  border-radius: 12px;
  color: var(--ink);
  background: transparent;
  font-weight: 900;
  cursor: pointer;
  font: inherit;
}

.segmented button.active {
  color: #08120f;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 10px 22px rgba(0, 0, 0, 0.22);
}

.auth-submit {
  width: 100%;
  border: 0;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 14px 30px rgba(55, 184, 135, 0.18);
}

#portal-auth-status,
#admin-password-status {
  min-height: 18px;
  color: var(--muted);
}

#portal-auth-status[data-type="error"],
#admin-password-status[data-type="error"] {
  color: #ffb4c0;
}

#admin-password-status[data-type="success"] {
  color: #9bf0c3;
}

.portal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  align-content: center;
}

.game-card,
.admin-choice {
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.game-card {
  min-height: 520px;
  padding: 24px;
  display: grid;
  grid-template-rows: 1fr auto auto;
  gap: 22px;
  overflow: hidden;
}

.game-visual {
  min-height: 220px;
  align-self: stretch;
}

.cards-visual {
  position: relative;
}

.cards-visual img {
  position: absolute;
  width: min(34%, 150px);
  border-radius: 12px;
  filter: drop-shadow(0 22px 28px rgba(0, 0, 0, 0.34));
}

.cards-visual img:nth-child(1) { left: 6%; top: 18%; rotate: -12deg; }
.cards-visual img:nth-child(2) { left: 32%; top: 8%; rotate: 5deg; }
.cards-visual img:nth-child(3) { left: 58%; top: 20%; rotate: 14deg; }

.sea-visual {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(38, 126, 170, 0.8), rgba(20, 76, 121, 0.82));
}

.sea-visual span {
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.15);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.16);
}

.sea-visual .ship {
  background: linear-gradient(135deg, #92a4af, #364858);
}

.sea-visual .hit {
  background: var(--danger);
  box-shadow: 0 0 0 8px rgba(223, 95, 114, 0.14), 0 0 22px rgba(223, 95, 114, 0.45);
}

.eyebrow {
  display: block;
  margin-bottom: 8px;
  text-transform: uppercase;
  font-size: 12px;
  font-weight: 900;
}

h1 {
  margin: 0;
  font-size: clamp(34px, 5vw, 62px);
  line-height: 1;
}

p {
  max-width: 30rem;
  margin: 12px 0 0;
  line-height: 1.45;
}

.primary-link {
  min-height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #08120f;
  font-weight: 900;
}

.admin-shell {
  align-content: start;
}

.admin-choice {
  padding: 24px;
  align-self: center;
}

.admin-choice h1 {
  font-size: clamp(28px, 4vw, 44px);
  margin-bottom: 18px;
}

.admin-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.admin-card {
  min-height: 140px;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--panel-strong);
}

.admin-card strong {
  font-size: 24px;
}

.admin-password-form {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.admin-password-form h2 {
  margin: 0;
}

@media (max-width: 760px) {
  .portal-shell {
    min-height: 100dvh;
    padding: 12px;
    gap: 14px;
  }

  .portal-top {
    align-items: stretch;
    flex-direction: column;
  }

  .portal-top nav a,
  .portal-session,
  .portal-session span,
  .portal-session button {
    width: 100%;
    justify-content: center;
  }

  .portal-grid,
  .admin-grid,
  .auth-panel {
    grid-template-columns: 1fr;
  }

  .auth-panel {
    padding: 14px;
    border-radius: 22px;
  }

  .auth-copy {
    min-height: auto;
    padding: 4px 4px 2px;
    gap: 10px;
  }

  .auth-copy h1 {
    font-size: 44px;
  }

  .auth-copy p {
    font-size: 16px;
  }

  .auth-form {
    padding: 14px;
    border-radius: 18px;
  }

  .game-card {
    min-height: auto;
    padding: 16px;
    border-radius: 18px;
  }

  .game-visual {
    min-height: 156px;
  }

  .primary-link {
    min-height: 52px;
  }
}
