:root {
  color-scheme: dark;
  --bg: #121318;
  --panel: #1e1f25;
  --border: #292a2f;
  --primary: #ffc174;
  --action: #f59e0b;
  --text: #e3e1e9;
  --muted: #a8a5b0;
  --success: #34d399;
  --danger: #f87171;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0 auto;
  padding: 32px 24px 64px;
  max-width: 1200px;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
  font-family: 'Chivo', sans-serif;
  line-height: 1.6;
}

h1, h2, h3 {
  font-family: 'Space Grotesk', sans-serif;
  line-height: 1.3;
}

h1 {
  color: var(--primary);
  font-size: 32px;
  letter-spacing: 2px;
}

h2 {
  font-size: 24px;
}

h3 {
  font-size: 19px;
}

section, #login {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 24px;
  margin: 20px 0;
}

button, input, select, textarea {
  font: inherit;
}

button {
  min-height: 44px;
  padding: 10px 20px;
  margin: 4px;
  border: 1px solid var(--action);
  border-radius: 8px;
  background: var(--action);
  color: #121318;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}

button:hover:not(:disabled) {
  background: var(--primary);
}

button:disabled {
  opacity: .4;
  cursor: not-allowed;
}

input, select, textarea {
  max-width: 100%;
  padding: 10px 12px;
  background: var(--bg);
  border: 1px solid #454650;
  border-radius: 8px;
  color: var(--text);
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 3px;
}

label {
  display: inline-block;
  margin: 6px 0;
}

textarea {
  min-height: 100px;
  resize: vertical;
}

table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--primary);
}

#judge-benar {
  background: #059669;
  border-color: #34d399;
  color: white;
}

#judge-salah {
  background: #b91c1c;
  border-color: #f87171;
  color: white;
}

#judge-benar:hover:not(:disabled) {
  background: #047857;
}

#judge-salah:hover:not(:disabled) {
  background: #991b1b;
}

@media (max-width: 640px) {
  body {
    padding: 16px 12px 40px;
  }

  section, #login {
    padding: 16px;
  }

  table input {
    width: 100%;
    min-width: 0;
  }

  th, td {
    padding: 5px;
  }
}

/* Host login layout */

body:has(#login:not([hidden])) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#login {
  width: 100%;
  max-width: 420px;
  padding: 32px;
  border: 1px solid #36363e;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}

#login label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 20px;
  font-size: 14px;
  font-weight: 500;
}

#login input {
  width: 100%;
  min-height: 48px;
}

#login button {
  width: 100%;
  min-height: 48px;
  margin: 8px 0 0;
}

@media (max-width: 480px) {
  #login {
    padding: 24px;
  }
}


/* ARENA brand identity */

.host-brand {
  text-align: center;
  margin-bottom: 8px;
}

.host-logo {
  display: block;
  width: 72px;
  height: auto;
  margin: 0 auto 12px;
  filter: drop-shadow(0 0 16px rgba(245,158,11,.26));
}

.host-brand h1 {
  font-size: 42px;
  font-weight: 700;
  letter-spacing: .22em;
  margin: 0;
  padding-left: .22em;
  color: var(--primary);
}

.host-tagline {
  font-size: 11px;
  letter-spacing: .18em;
  color: var(--muted);
  margin: 6px 0 24px;
}

.host-brand h2 {
  font-size: 24px;
  font-weight: 600;
  margin: 0;
}


/* Compact dashboard header after login */

body:has(#login[hidden]) .host-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  padding: 12px 0 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid #36363e;
}

body:has(#login[hidden]) .host-logo {
  width: 44px;
  margin: 0;
}

body:has(#login[hidden]) .host-brand h1 {
  font-size: 26px;
  letter-spacing: .18em;
  padding-left: 0;
}

body:has(#login[hidden]) .host-tagline {
  display: none;
}

body:has(#login[hidden]) .host-brand h2 {
  font-size: 13px;
  color: var(--muted);
  margin-left: auto;
  text-transform: uppercase;
  letter-spacing: .08em;
}

@media (max-width: 480px) {
  body:has(#login[hidden]) .host-brand {
    flex-wrap: wrap;
  }

  body:has(#login[hidden]) .host-brand h2 {
    width: 100%;
    margin-left: 0;
  }
}


/* Question preparation panel */

#question-panel > h2 {
  margin-top: 0;
  color: var(--primary);
}

#ai-question-generator,
#survival-draft {
  background: #17181e;
  border-color: #36363e;
}

#ai-question-generator h3,
#survival-draft h3 {
  color: var(--primary);
  margin-top: 0;
}

#ai-add-topic {
  background: transparent;
  color: var(--primary);
  border-color: var(--action);
}

#ai-add-topic:hover:not(:disabled) {
  background: rgba(245,158,11,.1);
}

#manual-question-details {
  padding: 16px;
  margin-bottom: 24px;
  background: var(--panel);
  border: 1px solid #36363e;
  border-radius: 10px;
}

#ai-topic {
  min-height: 44px;
}

#ai-package-topics input {
  width: 76px;
}

#question-panel > p,
#ai-question-generator > p,
#survival-draft > p {
  color: var(--muted);
  font-size: 14px;
}

#status {
  color: var(--success);
  font-weight: 600;
}


/* Room code card */

.room-code-card {
  padding: 24px 12px;
  margin-bottom: 24px;
  background: #121318;
  border: 1px solid rgba(245,158,11,.4);
  border-radius: 12px;
  text-align: center;
}

.room-code-label {
  margin: 0 0 8px;
  font-family: 'Space Grotesk', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .2em;
  color: var(--muted);
}

.room-code-value {
  font-family: 'Space Grotesk', sans-serif;
  font-size: clamp(24px, 4vw, 36px);
  font-weight: 700;
  letter-spacing: .12em;
  color: var(--primary);
  overflow-wrap: anywhere;
  text-shadow: 0 0 20px rgba(245,158,11,.2);
}

.room-code-hint {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
}


/* Responsive Host dashboard */

@media (min-width: 1024px) {
  body:has(#login[hidden]) {
    display: grid;
    grid-template-columns: minmax(0, 1.85fr) minmax(0, 1fr);
    column-gap: 24px;
    align-content: start;
    align-items: start;
  }

  .host-brand,
  #status {
    grid-column: 1 / -1;
  }

  #create-room {
    grid-column: 1 / -1;
    justify-self: start;
    margin: 0;
  }

  #question-panel {
    grid-column: 1;
    min-width: 0;
  }

  #lobby {
    grid-column: 2;
    min-width: 0;
  }
}

#lobby > h2 {
  color: var(--primary);
}

#players > section {
  background: #121318;
  padding: 16px;
  margin: 12px 0;
  border-color: #36363e;
  border-radius: 10px;
}

#players h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

#players ul {
  padding-left: 20px;
  margin: 0;
}

#players li {
  padding: 4px 0;
  overflow-wrap: anywhere;
}

#start-survival {
  width: 100%;
  margin: 16px 0 0;
}


/* Secondary question actions */

#question-panel .question-remove,
#question-panel .question-retry {
  background: transparent;
  border: none;
  color: var(--question-action, #38bdf8);
  box-shadow: none;
  font-weight: 500;
  padding: 6px 10px;
  margin: 2px;
}

#question-panel .question-remove {
  font-size: 24px;
  line-height: 1;
  min-width: 36px;
  min-height: 36px;
}

#question-panel .question-remove:hover:not(:disabled) {
  background: transparent;
  color: var(--danger);
}

#question-panel .question-retry {
  font-size: 13px;
}

#question-panel .question-retry:hover:not(:disabled) {
  background: transparent;
  color: #7dd3fc;
  text-decoration: underline;
}


/* Generated question cards */

#ai-question-results > ol > li {
  position: relative;
  background: var(--bg);
  border: 1px solid #36363e;
  border-radius: 12px;
  padding: 20px;
  margin: 16px 0;
  transition: opacity .2s, background .2s;
}

#ai-question-results .question-added {
  opacity: .5;
  background: #191a20;
  border-color: #292a2f;
}

#ai-question-results .question-added button:disabled {
  background: #292a2f;
  border-color: #454650;
  color: #34d399;
  opacity: 1;
  cursor: not-allowed;
}

#ai-question-results .question-added input,
#ai-question-results .question-added select {
  cursor: not-allowed;
}


/* Question Management Color Standard */

#question-panel {
  --question-action: #38bdf8;
}

#question-panel > h2,
#question-panel h3,
#question-panel h4,
#question-panel summary {
  color: var(--question-action);
}

#question-panel button:not(.question-remove):not(.question-retry) {
  background: var(--question-action);
  border-color: var(--question-action);
  color: #082f49;
}

#question-panel button:not(.question-remove):not(.question-retry):hover:not(:disabled) {
  background: #7dd3fc;
}

#question-panel #ai-add-topic {
  background: transparent;
  border-color: var(--question-action);
  color: var(--question-action);
}

#question-panel #ai-add-topic:hover:not(:disabled) {
  background: rgba(56,189,248,.12);
}

#question-panel button:focus-visible {
  outline-color: var(--question-action);
}

#question-panel button:disabled {
  background: #292a2f !important;
  border-color: #454650 !important;
  color: #8b8d98 !important;
  opacity: .65;
}

#question-panel .question-added button:disabled {
  color: #34d399 !important;
  opacity: 1;
}


/* Draft question layout */

#survival-draft-questions {
  padding-left: 24px;
}

#survival-draft-questions > li {
  position: relative;
  padding: 18px 44px 18px 0;
  border-bottom: 1px solid #36363e;
  overflow-wrap: anywhere;
}

#survival-draft-questions > li:last-child {
  border-bottom: none;
}

#survival-draft-questions > li > .question-remove {
  position: absolute;
  top: 10px;
  right: 0;
  margin: 0;
}

#survival-draft-questions > li > strong {
  display: block;
  line-height: 1.5;
}

#survival-draft-questions > li > p {
  margin: 10px 0;
}


/* Question method tabs */

#question-method-tabs {
  display: flex;
  gap: 8px;
  margin-top: 20px;
  margin-bottom: 16px;
}

#question-method-tabs .question-method-tab {
  flex: 1;
  margin: 0;
  padding: 12px 16px;
  border: 1px solid #38bdf8;
  border-radius: 8px;
  background: #22232a;
  color: #38bdf8;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, color .2s;
}

#question-method-tabs .question-method-tab.active {
  background: #38bdf8;
  color: #101820;
}

#question-method-tabs .question-method-tab:not(.active):hover {
  background: rgba(56, 189, 248, .12);
}

#ai-question-generator[hidden],
#manual-question-details[hidden] {
  display: none !important;
}

#manual-question-details {
  background: #17181e;
  border-color: #36363e;
  margin-bottom: 16px;
}

#manual-question-details > p {
  color: var(--muted);
  font-size: 14px;
}

#ai-question-title {
  display: none;
}


/* Refine question tabs and manual form */

#question-method-tabs button.question-method-tab:not(.active) {
  background: #17181e !important;
  color: #38bdf8 !important;
  border: 1px solid #38bdf8 !important;
}

#question-method-tabs button.question-method-tab.active {
  background: #38bdf8 !important;
  color: #101820 !important;
}

#question-method-tabs button.question-method-tab:not(.active):hover {
  background: rgba(56,189,248,.12) !important;
}

#manual-question-form {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

#manual-question-form > p {
  margin: 0;
  grid-column: 1 / -1;
}

#manual-question-form > p > label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
}

#manual-question-form input,
#manual-question-form textarea,
#manual-question-form select {
  width: 100%;
  max-width: none;
  box-sizing: border-box;
  margin: 0;
}

#manual-question-form textarea {
  min-height: 90px;
  resize: vertical;
}

#manual-question-form > p:nth-of-type(6) {
  grid-column: 1;
  grid-row: 6;
}

#manual-question-form > p:nth-of-type(8) {
  grid-column: 2;
  grid-row: 6;
}

#manual-question-form > p:nth-of-type(7) {
  grid-column: 1 / -1;
  grid-row: 7;
}

#manual-question-form > button {
  grid-column: 1 / -1;
  width: 100%;
  margin: 6px 0 0;
}

@media (max-width: 480px) {
  #manual-question-form {
    grid-template-columns: 1fr;
  }

  #manual-question-form > p:nth-of-type(n) {
    grid-column: 1;
    grid-row: auto;
  }
}


/* Game Control Panel */

#game-control-panel[hidden] {
  display: none !important;
}

#game-control-panel {
  min-width: 0;
}

#game-control-title {
  color: var(--primary);
  margin-top: 0;
  margin-bottom: 12px;
}

#game-control-status {
  color: #4ade80;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 24px;
}

#game-control-panel #survival-controls {
  min-width: 0;
}

#game-control-panel #question-number {
  color: var(--primary);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .08em;
}

#game-control-panel #question {
  font-size: 24px;
  font-weight: 600;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

@media (min-width: 1024px) {
  #game-control-panel {
    grid-column: 1;
    min-width: 0;
  }
}

@media (max-width: 640px) {
  #game-control-panel #question {
    font-size: 20px;
  }
}


/* Survival Control Panel refinement */

#game-control-panel #show-question:disabled,
#game-control-panel #start-answer:disabled,
#game-control-panel #reveal-answer:disabled {
  display: none;
}

#game-control-panel #start-final-battle {
  background: transparent;
  border: 1px solid #f59e0b;
  color: #ffb64c;
}

#game-control-panel #start-final-battle:hover:not(:disabled) {
  background: rgba(245,158,11,.12);
}

#game-control-panel #revealed-answer {
  font-size: 18px;
  font-weight: 600;
}

#game-control-panel #surviving-warriors {
  color: #a1a1aa;
  font-size: 14px;
}

#game-control-panel #survival-controls > button:not([hidden]) {
  margin-left: 0;
}

body:has(#game-control-panel:not([hidden])) > #status {
  display: none;
}


/* Host Survival question options */

#host-question-options[hidden],
#host-answer-key[hidden] {
  display: none !important;
}

#host-question-options {
  display: grid;
  gap: 10px;
  margin: 20px 0;
}

.host-question-option {
  background: #121318;
  border: 1px solid #36363e;
  border-radius: 8px;
  padding: 12px 16px;
  font-size: 17px;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.host-question-option.host-option-correct {
  background: #163827;
  border-color: #4ade80;
  color: #86efac;
}

.host-option-correct::after {
  content: " \2713";
  color: #4ade80;
  font-weight: 700;
}

#host-answer-key {
  color: #86efac;
  font-size: 14px;
  font-weight: 600;
  margin: 12px 0 24px;
}


/* Warrior survival status */

.warrior-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin: 16px 0;
}

.warrior-alive,
.warrior-fallen {
  background: #121318;
  border: 1px solid #36363e;
  border-radius: 8px;
  padding: 14px 8px;
  text-align: center;
  font-size: 16px;
  font-weight: 600;
}

.warrior-alive {
  color: #4ade80;
}

.warrior-fallen {
  color: #f87171;
}

.warrior-group-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 0;
}

.warrior-hearts {
  display: inline-flex;
  gap: 6px;
  font-size: 24px;
  line-height: 1;
}

.heart-alive {
  color: #f87171;
}

.heart-lost {
  color: #52525b;
}

.warrior-group-count {
  color: #a1a1aa;
  font-size: 13px;
  font-weight: 500;
}

#players > section > ul {
  padding-left: 18px;
  margin-bottom: 0;
}

#players > section > ul > li {
  padding: 4px 0;
  overflow-wrap: anywhere;
}


/* Add spacing between category label and dropdown */
#ai-question-form label[for="ai-topic"] {
  margin-right: 12px;
}

/* Generated question form label spacing */
#ai-question-results form label > input,
#ai-question-results form label > select {
  margin-left: 12px;
}

/* Final Battle Control Panel */
#final-battle-view {
  background: transparent;
  border: 0;
  padding: 0;
  margin: 0;
}

#final-battle-view > h2 {
  display: none;
}

#final-battle-finalists {
  color: var(--muted);
  font-size: 16px;
  font-weight: 600;
}

#final-round {
  color: var(--primary);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: .08em;
}

#buzzer-status {
  font-size: 18px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}

#buzzer-winner {
  background: rgba(245, 158, 11, .08);
  border: 1px solid #f59e0b;
  border-radius: 12px;
  padding: 24px 16px;
  color: #ffb64c;
  font-size: 24px;
  font-weight: 700;
  text-align: center;
  overflow-wrap: anywhere;
}


/* Final Battle action buttons */
#final-battle-view > button {
  min-height: 48px;
  padding: 12px 24px;
  font-size: 16px;
}

#judge-benar {
  background: #059669;
  border-color: #059669;
  color: #ffffff;
  min-width: 120px;
}

#judge-benar:hover:not(:disabled) {
  background: #047857;
}

#judge-salah {
  background: #dc2626;
  border-color: #dc2626;
  color: #ffffff;
  min-width: 120px;
}

#judge-salah:hover:not(:disabled) {
  background: #b91c1c;
}

/* Final Battle Leaderboard */
#final-leaderboard {
  background: transparent;
  border: 0;
  padding: 0;
  margin: 20px 0 0;
}

#final-leaderboard > h3 {
  color: var(--primary);
  font-size: 20px;
  letter-spacing: .06em;
  text-transform: uppercase;
}

#final-leaderboard-list {
  padding-left: 30px;
  margin-bottom: 0;
}

#final-leaderboard-list > li {
  background: #121318;
  border: 1px solid #36363e;
  border-radius: 8px;
  margin-bottom: 10px;
  padding: 14px 12px;
  font-size: 17px;
  font-weight: 600;
  overflow-wrap: anywhere;
}

#final-leaderboard-list > li::marker {
  color: var(--primary);
  font-weight: 700;
}

/* Final Battle buzzer state indicators */
#buzzer-status {
  padding: 14px 16px;
  border-radius: 8px;
  text-align: center;
}

#buzzer-status[data-state="closed"] {
  background: #26272e;
  color: #a1a1aa;
}

#buzzer-status[data-state="open"] {
  background: #142b22;
  color: #34d399;
  border: 1px solid #059669;
}

#buzzer-status[data-state="completed"] {
  background: #302519;
  color: #ffb64c;
}



/* Leaderboard name and score layout */
#final-leaderboard-list > li {
  position: relative;
  padding-right: 90px;
}

.leaderboard-name {
  display: block;
  overflow-wrap: anywhere;
}

.leaderboard-score {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 20px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.leaderboard-score[data-sign="positive"] {
  color: #ffb64c;
}

.leaderboard-score[data-sign="zero"] {
  color: #a1a1aa;
}

.leaderboard-score[data-sign="negative"] {
  color: #f87171;
}


/* Final Battle judgement result card */
#final-judgement-result {
  padding: 24px 16px;
  margin: 16px 0;
  border: 1px solid;
  border-radius: 12px;
  text-align: center;
}

#final-judgement-result[data-result="correct"] {
  background: #142b22;
  border-color: #059669;
  color: #34d399;
}

#final-judgement-result[data-result="wrong"] {
  background: #301b20;
  border-color: #dc2626;
  color: #f87171;
}

#final-judgement-name {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 8px;
  overflow-wrap: anywhere;
}

#final-judgement-points {
  font-size: 32px;
  font-weight: 700;
  margin: 0;
}


/* ARENA Champion Celebration */
#final-outcome {
  background: radial-gradient(
    ellipse at top,
    rgba(245, 158, 11, .15),
    #17181e 70%
  );
  border: 1px solid #a57429;
  border-radius: 16px;
  padding: 36px 20px;
  margin: 24px 0 0;
  text-align: center;
}

#final-outcome-trophy {
  font-size: 80px;
  line-height: 1.3;
  filter: drop-shadow(0 0 24px rgba(245, 158, 11, .45));
  margin-bottom: 16px;
}

#final-outcome-title {
  color: #ffb64c;
  font-size: 24px;
  letter-spacing: .12em;
  margin: 12px 0;
}

#final-outcome-winner {
  color: #ffffff;
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 800;
  margin: 20px 0;
  overflow-wrap: anywhere;
}

#final-outcome-score {
  color: #ffb64c;
  font-size: 32px;
  font-weight: 700;
  margin: 12px 0;
}


/* ARENA Draw Celebration */
#final-outcome[data-outcome="draw"] {
  background: radial-gradient(
    ellipse at top,
    rgba(203, 213, 225, .15),
    #17181e 70%
  );
  border-color: #94a3b8;
}

#final-outcome[data-outcome="draw"] #final-outcome-title,
#final-outcome[data-outcome="draw"] #final-outcome-score {
  color: #cbd5e1;
}

#final-outcome[data-outcome="draw"] #final-outcome-trophy {
  filter: grayscale(1) drop-shadow(0 0 20px rgba(203, 213, 225, .3));
}


/* ARENA Survival Champion Celebration */
#survival-outcome[data-outcome="winner"] {
  background: radial-gradient(
    ellipse at top,
    rgba(245, 158, 11, .15),
    #17181e 70%
  );
  border: 1px solid #a57429;
  border-radius: 16px;
  padding: 36px 20px;
  margin: 24px 0 0;
  text-align: center;
}

.survival-champion-trophy {
  display: block;
  font-size: 80px;
  line-height: 1.3;
  filter: drop-shadow(0 0 24px rgba(245, 158, 11, .45));
  margin-bottom: 16px;
}

.survival-champion-title {
  display: block;
  color: #ffb64c;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: .12em;
}

.survival-champion-name {
  display: block;
  color: #ffffff;
  font-size: clamp(32px, 5vw, 48px);
  font-weight: 800;
  margin: 20px 0;
  overflow-wrap: anywhere;
}

.survival-champion-tagline {
  display: block;
  color: #d6b77d;
  font-size: 16px;
  font-style: italic;
}
