/* GPN DIN font */
@font-face {
  font-family: "GPN DIN";
  src: url("/static/fonts/GPN_DIN-Regular.otf") format("opentype");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "GPN DIN";
  src: url("/static/fonts/GPN_DIN-Medium.otf") format("opentype");
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "GPN DIN";
  src: url("/static/fonts/GPN_DIN-Bold.otf") format("opentype");
  font-weight: 700; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "GPN DIN";
  src: url("/static/fonts/GPN_DIN-Italic.otf") format("opentype");
  font-weight: 400; font-style: italic; font-display: swap;
}

/* Brand palette */
:root {
  --gpn-blue-dark: #1c3d70;
  --gpn-blue: #2563ad;
  --gpn-blue-light: #3d8bcd;
  --gpn-accent: #51b1e2;
  --gpn-bg: #ecf3fb;
  --gpn-text: #1a2a44;
  --gpn-muted: #6b7c97;
  --gpn-white: #ffffff;
  --gpn-success: #2e8b57;
  --gpn-warning: #d6a000;
  --gpn-danger:  #c0392b;
  --gpn-border: #d4dfee;
}

* { box-sizing: border-box; }

body {
  font-family: "GPN DIN", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--gpn-text);
  background: var(--gpn-bg);
  margin: 0;
  line-height: 1.5;
}

a { color: var(--gpn-blue); text-decoration: none; }
a:hover { color: var(--gpn-blue-dark); text-decoration: underline; }

h1, h2, h3, h4 { font-family: "GPN DIN", sans-serif; color: var(--gpn-blue-dark); margin-top: 0; }
h1 { font-size: 1.8rem; font-weight: 700; }
h2 { font-size: 1.3rem; font-weight: 700; margin-top: 1.4em; }
h3 { font-size: 1.1rem; font-weight: 500; }

button, .btn, input[type="submit"] {
  font-family: inherit;
  font-weight: 500;
  background: var(--gpn-blue);
  color: var(--gpn-white);
  border: none;
  padding: 0.55em 1.2em;
  border-radius: 6px;
  cursor: pointer;
  font-size: 0.95rem;
  transition: background 0.15s;
}
button:hover, .btn:hover { background: var(--gpn-blue-dark); color: white; text-decoration: none; }
button.secondary { background: rgba(37,99,173,0.12); color: var(--gpn-blue-dark); }
button.secondary:hover { background: rgba(37,99,173,0.2); }
button.danger { background: var(--gpn-danger); }
button.danger:hover { background: #962d22; }

input[type="text"], input[type="number"], input[type="email"],
input[type="password"], textarea, select {
  font-family: inherit;
  font-size: 1rem;
  padding: 0.55em 0.75em;
  border: 1px solid var(--gpn-border);
  border-radius: 4px;
  background: white;
  color: var(--gpn-text);
}
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--gpn-blue-light);
  box-shadow: 0 0 0 3px rgba(61,139,205,0.15);
}

textarea { resize: vertical; min-height: 80px; font-family: inherit; }

.card {
  background: white;
  border-radius: 10px;
  padding: 1.5em;
  box-shadow: 0 2px 8px rgba(28,61,112,0.08);
  margin-bottom: 1em;
}

.app-header {
  background: linear-gradient(135deg, var(--gpn-blue-dark) 0%, var(--gpn-blue) 100%);
  color: white;
  padding: 0.9em 1.5em;
  display: flex;
  align-items: center;
  gap: 1em;
  box-shadow: 0 2px 12px rgba(28,61,112,0.15);
}
.app-header img.logo { height: 36px; }
.app-header .title { font-weight: 500; font-size: 1.05rem; flex: 1; }
.app-header nav a {
  color: rgba(255,255,255,0.85);
  margin-left: 1em;
  font-size: 0.95rem;
  text-decoration: none;
}
.app-header nav a:hover { color: white; text-decoration: underline; }

.app-main { max-width: 1100px; margin: 1.5em auto; padding: 0 1.5em; }

.status {
  display: inline-block;
  padding: 0.2em 0.7em;
  border-radius: 999px;
  font-size: 0.82em;
  font-weight: 500;
  letter-spacing: 0.02em;
}
.status-draft       { background: #e8edf4; color: #6b7c97; }
.status-ready       { background: #fff4d6; color: #8a6500; }
.status-in_progress { background: #d6f0e2; color: #196f3d; }
.status-running     { background: #d6f0e2; color: #196f3d; }
.status-pending     { background: #e8edf4; color: #6b7c97; }
.status-grace       { background: #fff4d6; color: #8a6500; }
.status-scoring     { background: #fde8d4; color: #a45a00; }
.status-completed   { background: #d4dfee; color: #1c3d70; }
.status-ended       { background: #fadbd8; color: #922b21; }
.status-archived    { background: #d6dbdf; color: #566573; }

table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(28,61,112,0.06);
}
th { background: var(--gpn-blue-dark); color: white; text-align: left; padding: 0.7em 1em; font-weight: 500; font-size: 0.92em; }
td { padding: 0.7em 1em; border-bottom: 1px solid var(--gpn-border); }
tr:last-child td { border-bottom: none; }
tr:hover { background: rgba(37,99,173,0.04); }

.round-list { list-style: none; padding: 0; margin: 0; }
.round-item {
  display: flex;
  align-items: center;
  gap: 1em;
  background: white;
  border-radius: 8px;
  padding: 0.8em 1.2em;
  margin-bottom: 0.6em;
  box-shadow: 0 1px 3px rgba(28,61,112,0.06);
}
.round-icon { width: 56px; height: 56px; flex-shrink: 0; }
.round-icon img { width: 100%; height: 100%; object-fit: contain; }
.round-meta { flex: 1; }
.round-meta .round-title { font-weight: 500; font-size: 1.05rem; color: var(--gpn-blue-dark); }
.round-meta .round-sub   { font-size: 0.88rem; color: var(--gpn-muted); margin-top: 0.15em; }
.round-actions { display: flex; gap: 0.4em; flex-wrap: wrap; }
.round-actions form { margin: 0; }

.empty-state {
  text-align: center;
  padding: 3em 1em;
  color: var(--gpn-muted);
  background: white;
  border-radius: 8px;
}

/* Player mobile-first */
.player-shell {
  max-width: 540px;
  margin: 0 auto;
  padding: 1em;
}
.team-banner {
  background: linear-gradient(135deg, var(--gpn-blue-dark), var(--gpn-blue));
  color: white;
  border-radius: 10px;
  padding: 1em 1.2em;
  margin-bottom: 1em;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
}
.team-banner .team-name { font-size: 1.3rem; font-weight: 700; }
.team-banner .team-score { font-size: 1.5rem; font-weight: 700; }
.team-banner .team-score-label { font-size: 0.75rem; opacity: 0.8; text-transform: uppercase; letter-spacing: 0.05em; }

.round-card {
  background: white;
  border-radius: 10px;
  padding: 1.2em;
  box-shadow: 0 2px 6px rgba(28,61,112,0.08);
  margin-bottom: 1em;
  overflow: hidden;
  min-width: 0;
}
.question-block { min-width: 0; }
.question-block > * { min-width: 0; max-width: 100%; }
.round-card .round-header {
  display: flex;
  align-items: center;
  gap: 0.8em;
  margin-bottom: 0.8em;
  padding-bottom: 0.8em;
  border-bottom: 1px solid var(--gpn-border);
}
.round-card .round-header img { width: 48px; height: 48px; }
.round-card .round-header .round-title { font-weight: 700; color: var(--gpn-blue-dark); font-size: 1.1rem; }

.inventory {
  background: white;
  border-radius: 10px;
  padding: 1em;
  margin-top: 1em;
}
.inventory h4 { font-size: 0.9rem; color: var(--gpn-muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 0 0 0.6em; }
.module-chip {
  display: inline-block;
  background: rgba(37,99,173,0.08);
  color: var(--gpn-blue-dark);
  padding: 0.3em 0.7em;
  border-radius: 999px;
  font-size: 0.85rem;
  margin: 0.1em;
}
.module-chip.mandatory   { background: rgba(46,139,87,0.15);  color: #1e5e3a; }
.module-chip.recommended { background: rgba(214,160,0,0.18);  color: #7a5800; }
.module-chip.optional    { background: rgba(108,124,151,0.15); color: #4a586c; }

/* Finale market/assembly layout */
.finale-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6em;
  margin-bottom: 1em;
}
.finale-stat {
  background: linear-gradient(135deg, var(--gpn-blue-dark), var(--gpn-blue));
  color: white;
  border-radius: 8px;
  padding: 0.7em 1em;
  text-align: center;
}
.finale-stat .label { font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em; opacity: 0.85; }
.finale-stat .value { font-size: 1.6rem; font-weight: 700; line-height: 1.1; margin-top: 0.15em; }

.section-title {
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gpn-muted);
  font-weight: 700;
  margin: 1.4em 0 0.5em;
}
.module-row {
  display: flex;
  align-items: center;
  gap: 0.6em;
  background: white;
  border: 1px solid var(--gpn-border);
  border-radius: 8px;
  padding: 0.7em 0.9em;
  margin-bottom: 0.4em;
}
.module-row.placed { background: rgba(46,139,87,0.06); border-color: rgba(46,139,87,0.3); }
.module-row .module-info { flex: 1; min-width: 0; }
.module-row .module-name { font-weight: 500; color: var(--gpn-text); display: block; word-break: break-word; }
.module-row .module-meta {
  font-size: 0.78rem;
  color: var(--gpn-muted);
  display: flex;
  gap: 0.4em;
  align-items: center;
  margin-top: 0.2em;
}
.module-row .badge {
  display: inline-block;
  padding: 0.1em 0.5em;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.module-row .badge.mandatory   { background: rgba(46,139,87,0.18);  color: #1e5e3a; }
.module-row .badge.recommended { background: rgba(214,160,0,0.20);  color: #7a5800; }
.module-row .badge.optional    { background: rgba(108,124,151,0.18); color: #4a586c; }
.module-row .price {
  font-weight: 700;
  color: var(--gpn-blue-dark);
  white-space: nowrap;
}
.module-row .price.free { color: var(--gpn-success); }
.module-row form { margin: 0; }
.module-row button { white-space: nowrap; padding: 0.4em 0.9em; font-size: 0.9rem; }

/* Question / answer form */
.question-block {
  padding: 1.2em 0;
  border-top: 1px solid var(--gpn-border);
}
.question-block:first-of-type { border-top: none; padding-top: 0.4em; }
.question-prompt {
  font-size: 1.02rem;
  line-height: 1.55;
  color: var(--gpn-text);
  margin: 0 0 0.8em;
}
.question-hint {
  background: rgba(61,139,205,0.06);
  border-left: 3px solid var(--gpn-blue-light);
  padding: 0.6em 0.9em;
  border-radius: 4px;
  margin: 0 0 1em;
  font-size: 0.95rem;
  color: var(--gpn-text);
}
.question-hint > summary {
  cursor: pointer;
  font-weight: 500;
  color: var(--gpn-blue-dark);
  list-style: none;
}
.question-hint > summary::before { content: "💡 "; }
.question-hint > summary::-webkit-details-marker { display: none; }
.question-hint[open] > summary { margin-bottom: 0.5em; }

.answer-form { display: flex; flex-direction: column; gap: 0.7em; min-width: 0; max-width: 100%; }
.answer-form textarea,
.answer-form input[type="text"],
.answer-form input[type="number"] {
  width: 100%;
  font-size: 1.05rem;
  padding: 0.7em 0.9em;
  min-height: 56px;
}
.answer-form textarea { min-height: 80px; }
.answer-form button {
  align-self: flex-end;
  min-width: 140px;
}
.answer-options { display: flex; flex-direction: column; gap: 0.5em; }
.answer-options label {
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.6em 0.9em;
  border: 1px solid var(--gpn-border);
  border-radius: 6px;
  background: white;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.answer-options label:hover { background: rgba(37,99,173,0.04); border-color: var(--gpn-blue-light); }
.answer-options label:has(input:checked) {
  background: rgba(37,99,173,0.08);
  border-color: var(--gpn-blue);
}
.answer-pairs {
  display: grid;
  grid-template-columns: minmax(60px, max-content) minmax(0, 1fr);
  gap: 0.5em 0.8em;
  align-items: center;
  width: 100%;
}
.answer-pairs > .pair-label {
  font-weight: 700;
  color: var(--gpn-blue-dark);
  text-align: right;
  font-size: 1rem;
  word-break: break-word;
}
.answer-pairs > select {
  margin: 0;
  font-size: 0.95rem;
  min-width: 0;
  width: 100%;
  max-width: 100%;
  text-overflow: ellipsis;
}
@media (max-width: 540px) {
  .answer-pairs { grid-template-columns: minmax(0, 1fr); gap: 0.2em 0; }
  .answer-pairs > .pair-label { text-align: left; margin-top: 0.6em; font-size: 0.9rem; }
}
/* Legacy alias */
.answer-row {
  display: flex;
  align-items: center;
  gap: 0.8em;
  padding: 0.4em 0;
}
.answer-row > strong { min-width: 80px; color: var(--gpn-blue-dark); flex-shrink: 0; }
.answer-row > select { flex: 1; min-width: 0; }

.answer-accepted {
  display: flex;
  align-items: center;
  gap: 0.6em;
  padding: 0.8em 1em;
  background: rgba(46,139,87,0.1);
  color: #1e5e3a;
  border-radius: 6px;
  font-weight: 500;
}
.answer-accepted::before { content: "✓"; font-size: 1.2rem; }
