/* Spilletid – playful, responsive UI */

:root {
  --st-lavender: #c4b5fd;
  --st-lavender-deep: #8b5cf6;
  --st-mint: #5eead4;
  --st-mint-soft: #ccfbf1;
  --st-coral: #fb7185;
  --st-coral-soft: #ffe4e6;
  --st-sun: #fcd34d;
  --st-sun-soft: #fef3c7;
  --st-sky: #7dd3fc;
  --st-text: #1e1b4b;
  --st-text-muted: #64748b;
  --st-white: #ffffff;
  --st-card: rgba(255, 255, 255, 0.92);
  --st-radius: 1.25rem;
  --st-radius-sm: 0.75rem;
  --st-shadow: 0 4px 24px rgba(91, 33, 182, 0.12);
  --st-shadow-hover: 0 8px 32px rgba(91, 33, 182, 0.18);
  --st-font: "Nunito", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body.st-app {
  margin: 0;
  min-height: 100vh;
  font-family: var(--st-font);
  font-size: 1rem;
  line-height: 1.5;
  color: var(--st-text);
  background: linear-gradient(135deg, #ddd6fe 0%, #a5f3fc 45%, #fef08a 100%);
  background-attachment: fixed;
}

body.st-app::before {
  content: "";
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle at 20% 80%, rgba(251, 113, 133, 0.15) 0%, transparent 45%),
    radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.12) 0%, transparent 40%);
  pointer-events: none;
  z-index: 0;
}

body.st-login {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--st-font);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.25rem;
  color: var(--st-text);
  background: linear-gradient(145deg, #a78bfa 0%, #34d399 50%, #fbbf24 100%);
  background-attachment: fixed;
  position: relative;
  overflow-x: hidden;
}

body.st-login::before {
  content: "🎮";
  position: absolute;
  font-size: clamp(8rem, 35vw, 14rem);
  opacity: 0.08;
  top: -2rem;
  right: -1rem;
  transform: rotate(18deg);
  pointer-events: none;
}

.st-shell {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0.75rem 1rem calc(2.5rem + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 768px) {
  .st-shell {
    padding: 1rem 1.5rem calc(3rem + env(safe-area-inset-bottom, 0px));
  }
}

/* Top bar */
.st-topbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.65rem 1rem;
  margin-bottom: 1.25rem;
  background: var(--st-card);
  backdrop-filter: blur(12px);
  border-radius: var(--st-radius);
  box-shadow: var(--st-shadow);
  border: 2px solid rgba(255, 255, 255, 0.8);
}

.st-topbar--admin {
  border-color: rgba(167, 139, 250, 0.5);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(237, 233, 254, 0.9));
}

.st-brand {
  font-weight: 800;
  font-size: 1.35rem;
  color: var(--st-lavender-deep);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  letter-spacing: -0.02em;
}

.st-brand:hover {
  color: #6d28d9;
}

.st-brand__icon {
  font-size: 1.5rem;
  filter: drop-shadow(0 2px 4px rgba(139, 92, 246, 0.3));
}

.st-pill {
  display: inline-block;
  margin-left: 0.35rem;
  padding: 0.15rem 0.55rem;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #fff;
  background: linear-gradient(135deg, var(--st-coral), #ec4899);
  border-radius: 999px;
  vertical-align: middle;
}

.st-nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: none;
  border-radius: var(--st-radius-sm);
  background: linear-gradient(135deg, var(--st-sun), var(--st-coral));
  color: #fff;
  font-size: 1.25rem;
  cursor: pointer;
  box-shadow: 0 2px 12px rgba(251, 113, 133, 0.4);
}

.st-nav-toggle:hover {
  filter: brightness(1.05);
}

.st-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.75rem;
}

.st-nav a {
  color: var(--st-lavender-deep);
  text-decoration: none;
  font-weight: 700;
  padding: 0.4rem 0.75rem;
  border-radius: var(--st-radius-sm);
  transition: background 0.15s, color 0.15s;
}

.st-nav a:hover {
  background: rgba(139, 92, 246, 0.12);
  color: #5b21b6;
}

.st-nav-logout {
  color: var(--st-coral) !important;
}

.st-nav-logout:hover {
  background: var(--st-coral-soft) !important;
}

@media (max-width: 767px) {
  .st-nav-toggle {
    display: flex;
  }

  .st-nav {
    display: none;
    position: fixed;
    top: 0;
    right: 0;
    z-index: 200;
    flex-direction: column;
    align-items: stretch;
    width: min(300px, 88vw);
    height: 100vh;
    height: 100dvh;
    margin: 0;
    padding: calc(4.5rem + env(safe-area-inset-top, 0px)) 1.25rem calc(2rem + env(safe-area-inset-bottom, 0px));
    background: linear-gradient(180deg, #fff 0%, #faf5ff 100%);
    box-shadow: -12px 0 40px rgba(30, 27, 75, 0.15);
    border-radius: 0;
    gap: 0.25rem;
  }

  .st-nav.is-open {
    display: flex;
  }

  .st-nav a {
    padding: 0.85rem 1rem;
    font-size: 1.05rem;
    border-radius: var(--st-radius-sm);
  }

  .st-topbar {
    position: sticky;
    top: max(0.5rem, env(safe-area-inset-top, 0px));
    z-index: 100;
  }
}

/* Main */
.st-main {
  position: relative;
  z-index: 1;
}

.st-main--narrow {
  max-width: 42rem;
}

.st-main--form {
  max-width: 40rem;
}

/* Cards */
.st-card {
  background: var(--st-card);
  backdrop-filter: blur(10px);
  border-radius: var(--st-radius);
  padding: 1.25rem 1.35rem;
  margin-bottom: 1.1rem;
  box-shadow: var(--st-shadow);
  border: 2px solid rgba(255, 255, 255, 0.85);
  transition: box-shadow 0.2s;
}

.st-card:hover {
  box-shadow: var(--st-shadow-hover);
}

.st-card h1,
.st-card h2,
.st-card__title {
  margin: 0 0 0.75rem;
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--st-text);
  letter-spacing: -0.02em;
}

.st-card h2 {
  font-size: 1.15rem;
}

/* Login */
.st-login-card {
  width: 100%;
  max-width: 400px;
  padding: 2rem 1.75rem;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(16px);
  border-radius: 1.75rem;
  box-shadow: 0 24px 64px rgba(30, 27, 75, 0.2);
  border: 3px solid rgba(255, 255, 255, 0.9);
  position: relative;
  z-index: 1;
}

.st-login-card h1 {
  margin: 0 0 0.25rem;
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--st-lavender-deep), #ec4899);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.st-login-remember {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin: 1rem 0 0.25rem;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--st-text-muted);
  cursor: pointer;
  line-height: 1.35;
}

.st-login-remember input {
  margin-top: 0.2rem;
  flex-shrink: 0;
}

.st-login-card .st-login-tag {
  margin: 0 0 1.25rem;
  font-size: 0.95rem;
  color: var(--st-text-muted);
  font-weight: 600;
}

/* Typography */
.st-lead {
  color: var(--st-text-muted);
  font-size: 0.95rem;
  margin: 0 0 1rem;
  font-weight: 600;
}

.st-muted {
  color: var(--st-text-muted);
  font-size: 0.875rem;
}

h1.st-page-title {
  margin: 0 0 1rem;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 800;
  color: var(--st-text);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
}

/* Links (inline in prose) */
.st-app a:not(.st-brand):not(.st-btn):not(.st-nav a):not(.st-back) {
  color: var(--st-lavender-deep);
  font-weight: 700;
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.st-app a:not(.st-brand):not(.st-btn):not(.st-nav a):not(.st-back):hover {
  color: #5b21b6;
}

.st-back {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin-bottom: 1rem;
  font-weight: 700;
  color: var(--st-text);
  text-decoration: none;
  padding: 0.35rem 0.65rem;
  background: rgba(255, 255, 255, 0.65);
  border-radius: var(--st-radius-sm);
}

.st-back:hover {
  background: rgba(255, 255, 255, 0.95);
}

/* Buttons */
.st-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.6rem 1.15rem;
  font-family: inherit;
  font-size: 0.95rem;
  font-weight: 800;
  border: none;
  border-radius: var(--st-radius-sm);
  cursor: pointer;
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s;
}

.st-btn:active {
  transform: scale(0.98);
}

.st-btn--primary {
  color: #fff;
  background: linear-gradient(135deg, var(--st-lavender-deep), #7c3aed);
  box-shadow: 0 4px 16px rgba(124, 58, 237, 0.35);
}

.st-btn--primary:hover {
  filter: brightness(1.08);
  box-shadow: 0 6px 20px rgba(124, 58, 237, 0.45);
}

.st-btn--sun {
  color: #422006;
  background: linear-gradient(135deg, var(--st-sun), #fbbf24);
  box-shadow: 0 4px 16px rgba(251, 191, 36, 0.4);
}

.st-btn--sun:hover {
  filter: brightness(1.05);
}

button.st-btn--block,
.st-btn--block {
  width: 100%;
  margin-top: 1rem;
  padding: 0.85rem 1rem;
}

/* Forms */
.st-label {
  display: block;
  margin-top: 1rem;
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--st-text-muted);
}

.st-label:first-child,
.st-card .st-label:first-of-type,
form > .st-label:first-child {
  margin-top: 0;
}

.st-input,
.st-select,
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="time"],
select {
  width: 100%;
  max-width: 100%;
  margin-top: 0.35rem;
  padding: 0.65rem 0.85rem;
  font-family: inherit;
  font-size: 1rem;
  border: 2px solid rgba(139, 92, 246, 0.2);
  border-radius: var(--st-radius-sm);
  background: rgba(255, 255, 255, 0.95);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.st-input:focus,
.st-select:focus,
input:focus,
select:focus {
  outline: none;
  border-color: var(--st-lavender-deep);
  box-shadow: 0 0 0 4px rgba(139, 92, 246, 0.15);
}

.st-hint {
  font-size: 0.8rem;
  color: var(--st-text-muted);
  margin-top: 0.35rem;
  font-weight: 600;
}

/* Fieldsets */
.st-fieldset {
  border: 2px dashed rgba(139, 92, 246, 0.25);
  border-radius: var(--st-radius);
  margin-top: 1.25rem;
  padding: 1rem 1.1rem;
  background: rgba(255, 255, 255, 0.5);
}

.st-fieldset legend {
  padding: 0 0.5rem;
  font-weight: 800;
  color: var(--st-lavender-deep);
}

/* Grid rows */
.st-row2 {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.st-row3 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
}

@media (max-width: 640px) {
  .st-row2,
  .st-row3 {
    grid-template-columns: 1fr;
  }
}

/* Weekly window grid – horizontal scroll on small screens */
.st-win-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-top: 0.5rem;
  padding-bottom: 0.35rem;
}

.st-win-grid {
  display: grid;
  grid-template-columns: minmax(4rem, 1fr) auto auto auto;
  gap: 0.5rem 0.65rem;
  align-items: center;
  font-size: 0.875rem;
  min-width: min(100%, 22rem);
}

.st-win-grid input[type="time"] {
  width: auto;
  min-width: 5.5rem;
  max-width: 100%;
}

/* Tables */
.st-table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0.5rem -0.25rem;
  padding: 0 0.25rem;
  border-radius: var(--st-radius-sm);
}

.st-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  background: rgba(255, 255, 255, 0.7);
  border-radius: var(--st-radius-sm);
  overflow: hidden;
}

.st-table th,
.st-table td {
  text-align: left;
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid rgba(139, 92, 246, 0.12);
}

.st-table th {
  background: linear-gradient(180deg, rgba(237, 233, 254, 0.9), rgba(221, 214, 254, 0.6));
  font-weight: 800;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--st-lavender-deep);
}

.st-table tr:last-child td {
  border-bottom: none;
}

/* Alerts */
.st-alert {
  padding: 0.75rem 1rem;
  border-radius: var(--st-radius-sm);
  font-weight: 700;
  margin-bottom: 1rem;
  border: 2px solid transparent;
}

.st-alert--error,
.st-err,
.err {
  background: var(--st-coral-soft);
  color: #9f1239;
  border-color: rgba(251, 113, 133, 0.4);
}

.st-alert--success,
.st-msg,
.msg {
  background: var(--st-mint-soft);
  color: #065f46;
  border-color: rgba(94, 234, 212, 0.5);
}

.st-ok,
.ok {
  color: #047857;
  font-weight: 700;
}

/* Status badges (dashboard) */
.ok,
.bad,
.dash-state.ok,
.dash-state.bad {
  font-weight: 800;
}

.dash-state.ok,
.ok {
  color: #059669;
}

.dash-state.bad,
.bad {
  color: #e11d48;
}

/* Pairing code display */
.st-code-big {
  font-size: clamp(1.75rem, 6vw, 2.25rem);
  letter-spacing: 0.2em;
  font-weight: 800;
  font-family: ui-monospace, "Cascadia Code", monospace;
  margin: 1rem 0;
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, var(--st-sun-soft), #fef9c3);
  border-radius: var(--st-radius);
  border: 3px solid var(--st-sun);
  color: #713f12;
  text-align: center;
}

.code-cell,
.pair-code {
  font-family: ui-monospace, monospace;
  letter-spacing: 0.1em;
  font-weight: 800;
  color: var(--st-lavender-deep);
}

/* Dashboard usage line */
.dash-usage {
  font-size: 0.95rem;
  padding: 0.75rem 1rem;
  background: rgba(255, 255, 255, 0.6);
  border-radius: var(--st-radius-sm);
  border-left: 4px solid var(--st-mint);
  margin: 0.75rem 0;
}

.dash-state {
  font-weight: 800;
}

/* Admin: inline forms in tables */
.st-inline-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: flex-end;
  margin-top: 0.5rem;
}

.st-inline-form select {
  max-width: 100%;
  flex: 1 1 12rem;
}

/* Progress (if any) */
progress,
.st-progress {
  width: 100%;
  height: 0.65rem;
  border-radius: 999px;
  overflow: hidden;
}

/* Utility */
.st-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.st-stack {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.st-form-row {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.5rem 0.75rem;
  margin-top: 0.75rem;
}

.st-form-row input[type="number"] {
  width: auto;
  min-width: 5.5rem;
  max-width: 100%;
}

.st-form-row .st-btn {
  margin-top: 0;
}

section.st-section {
  margin-top: 1.75rem;
}

section.st-section h2 {
  font-size: 1.1rem;
  font-weight: 800;
  margin: 0 0 0.65rem;
  color: var(--st-lavender-deep);
}

table.codes,
table.pair-mini {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
  background: rgba(255, 255, 255, 0.85);
  border-radius: var(--st-radius-sm);
  overflow: hidden;
}

table.codes th,
table.codes td,
table.pair-mini th,
table.pair-mini td {
  padding: 0.55rem 0.65rem;
  border-bottom: 1px solid rgba(139, 92, 246, 0.1);
}

table.codes th,
table.pair-mini th {
  background: rgba(237, 233, 254, 0.8);
  font-weight: 800;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
