:root {
  --bg: #0d1117;
  --panel: #151b23;
  --panel-light: #1c2430;
  --border: #303b4a;
  --text: #edf2f7;
  --muted: #9ba8b7;
  --accent: #118117;
  --accent-dark: #016806;
  --success: #10af18;
  --danger: #e66b6b;
  --max-width: 900px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(
      circle at top,
      #1b2635 0,
      var(--bg) 45%
    );
  color: var(--text);
  font-family:
    Arial,
    Helvetica,
    sans-serif;
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  text-wrap: nowrap;
  min-width: 100px;
}


/* ---------------------------------------------------------------
   SITE
   --------------------------------------------------------------- */

.site-header {
  height: 58px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 14, 20, 0.9);
  
  font-weight:             400;
  font-size:               1.5rem;
  font-style:              italic;
  margin-bottom:           10px;
  letter-spacing:          -1px;
  
}

.site-header img {
  max-width:               100px;
  vertical-align:          middle;
  margin-right:            -2px;
}

.site-header a {
  color:                   var(--muted);
  text-decoration:         none;
}

.site-logo {
  max-width:               100px;
  vertical-align:          middle;
  margin-right:            -2px;
  margin-top:               2px;
}

.site-section {
  color: var(--muted);

  font-size: 12px;
  font-weight: bold;
  letter-spacing: 2px;
}


/* ---------------------------------------------------------------
   MAIN
   --------------------------------------------------------------- */

.game-shell {
  width: min(
    calc(100% - 32px),
    var(--max-width)
  );

  margin: 0 auto;
  padding: 25px 0 70px;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin: 0 10px 35px 10px;
}

.eyebrow {
  color: var(--accent);
  font-size: 11px;
  font-weight: bold;
  letter-spacing: 2px;
  text-transform: uppercase;
}

.game-header h1 {
  margin: 3px 0 0;
  font-size: 42px;
  line-height: 1;
}

.game-header h1 a {
  color: white;
  text-decoration: none;
}

.tagline {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 14px;
}

.game-code-display {
  text-align: right;
}

.game-code-display span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 2px;
}

.game-code-display strong {
  display: block;
  margin-top: 2px;
  color: var(--accent);
  font-size: 26px;
  letter-spacing: 4px;
}


/* ---------------------------------------------------------------
   SCREENS
   --------------------------------------------------------------- */

.screen {
  display: none;
}

.screen.active {
  display: block;
}


/* ---------------------------------------------------------------
   PANELS
   --------------------------------------------------------------- */

.intro-panel,
.action-card,
.players-panel,
.story-panel,
.writing-panel,
.winner-card,
.scores-panel,
.final-story-panel,
.waiting-panel {
  border: 1px solid var(--accent);
  background: rgba(21, 27, 35, 0.94);
  border-radius: 8px;
}

.intro-panel {
  padding: 26px;
  margin-bottom: 18px;
}

.intro-panel h2 {
  margin: 0 0 10px;
  font-size: 25px;
}

.intro-panel p,
.action-card p {
  max-width: 800px;
  margin: 0;
  color: var(--muted);
}


/* ---------------------------------------------------------------
   HOME
   --------------------------------------------------------------- */

.home-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.action-card {
  padding: 24px;
}

.action-card h3 {
  margin: 0 0 20px;
  font-size: 19px;
}

.action-card label,
.writing-panel label,
.scores-panel label {
  display: block;
  margin: 13px 0 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: bold;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--accent);
  border-radius: 5px;
  background: #0c1117;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
  transition:
    border-color 0.15s,
    box-shadow 0.15s;
}

input:focus,
textarea:focus {
  border-color: var(--success);
}

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

.action-card button {
  width: 100%;
  margin-top: 18px;
}


/* ---------------------------------------------------------------
   BUTTONS
   --------------------------------------------------------------- */

.primary-button,
.secondary-button {
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 5px;
  font-size: 13px;
  font-weight: bold;
}

.primary-button {
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--text);
  text-shadow: 0px 0px 3px black;
}

.primary-button:hover {
  filter:brightness(1.2);
}

.secondary-button {
  border: 1px solid var(--accent-dark);
  background: var(--panel-light);
  color: var(--text);
}

.secondary-button:hover {
  filter:brightness(1.2);
}

button:disabled, button:disabled:hover {
  cursor: not-allowed;
  filter: saturate(0);
  opacity: 0.45;
}


/* ---------------------------------------------------------------
   HEADINGS
   --------------------------------------------------------------- */

.screen-heading,
.round-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 20px;
}

.screen-heading h2,
.round-header h2,
.reveal-heading h2 {
  margin: 4px 0 0;
  font-size: 27px;
}

.room-code {
  text-align: right;
}

.room-code span {
  display: block;
  color: var(--muted);
  font-size: 10px;
  letter-spacing: 2px;
}

.room-code strong {
  color: var(--accent);
  font-size: 25px;
  letter-spacing: 4px;
}

.share-message {
  margin: -8px 0 20px;
  color: var(--muted);
}


/* ---------------------------------------------------------------
   PLAYERS
   --------------------------------------------------------------- */

.players-panel {
  padding: 20px;
  margin-bottom: 18px;
}

.players-panel h3,
.scores-panel h3,
.writing-panel h3 {
  margin: 0 0 14px;
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.player-list,
.score-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player,
.score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 11px 13px;
  border-radius: 5px;
  background: var(--panel-light);
}

.player-name {
  font-weight: bold;
}

.player-status {
  color: var(--muted);
  font-size: 12px;
}

.player-status.connected {
  color: var(--success);
}

.host-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 6px;
  border-radius: 3px;
  background: rgba(245, 166, 35, 0.14);
  color: var(--accent);
  font-size: 9px;
  font-weight: bold;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.lobby-actions,
.final-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}


/* ---------------------------------------------------------------
   OPENING / WRITING
   --------------------------------------------------------------- */

.form-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 10px;
}

.form-footer span {
  color: var(--muted);
  font-size: 12px;
}

.timer {
  min-width: 75px;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 5px;
  background: var(--panel);
  color: var(--accent);
  text-align: center;
  font-size: 20px;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
}

.timer.warning {
  color: var(--danger);
}

.story-panel {
  padding: 20px;
  margin-bottom: 18px;
}

.panel-label {
  margin-bottom: 12px;
  color: var(--accent);
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 2px;
}

.story-text {
  color: #d9e0e8;
  white-space: normal;
  overflow-wrap: break-word; 
  word-wrap: break-word;   
  font-family:
    Georgia,
    "Times New Roman",
    serif;
  font-size: 18px;
  line-height: 1.65;
}

.writing-panel {
  padding: 20px;
}

.waiting-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 38px;
  text-align: center;
}

.waiting-panel p {
  margin: 8px 0 3px;
  font-weight: bold;
}

.waiting-panel small {
  color: var(--muted);
}

.spinner {
  width: 28px;
  height: 28px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.checkmark {
  color: var(--success);
  font-size: 35px;
  font-weight: bold;
}


/* ---------------------------------------------------------------
   VOTING
   --------------------------------------------------------------- */

.voting-instruction {
  color: var(--muted);
  margin: 0 0 12px;
}

.vote-button {
  float:right;
  margin-left: 10px;
}

.entry-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.entry-button {
  width: 100%;
  padding: 17px;
  border: 1px solid var(--border);
  border-radius: 7px;
  background: var(--panel);
  color: var(--text);
  text-align: left;
  transition:
    border-color 0.15s,
    background 0.15s;
}

.entry-button:hover {
  border-color: var(--accent);
  background: var(--panel-light);
}

.entry-number {
  display: block;
  margin-bottom: 5px;
  color: var(--accent);
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 1px;
}

.entry-text {
  font-family:
    Georgia,
    "Times New Roman",
    serif;
  overflow-wrap: break-word; 
  word-wrap: break-word;  
  font-size: 17px;
  line-height: 1.5;
}


/* ---------------------------------------------------------------
   REVEAL
   --------------------------------------------------------------- */

.reveal-heading {
  text-align: center;
  margin-bottom: 22px;
}

.winner-card {
  padding: 30px;
  margin-bottom: 18px;
  text-align: center;
}

.winner-label {
  color: var(--accent);
  font-size: 10px;
  font-weight: bold;
  letter-spacing: 2px;
}

.winner-card blockquote {
  margin: 20px auto;
  max-width: 700px;
  font-family:
    Georgia,
    "Times New Roman",
    serif;
  font-size: 25px;
  line-height: 1.45;
}

.winner-attribution {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.winner-attribution span {
  color: var(--accent);
  font-weight: bold;
}

.scores-panel {
  padding: 20px;
}

.score-row strong {
  color: var(--accent);
}


/* ---------------------------------------------------------------
   FINISHED
   --------------------------------------------------------------- */

.final-story-panel {
  padding: 28px;
  margin-bottom: 18px;
}

.final-story {
  font-family:
    Georgia,
    "Times New Roman",
    serif;
  font-size: 19px;
  line-height: 1.75;
  overflow-wrap: break-word; 
  word-wrap: break-word;   
  white-space: pre-line;
}

.final-actions {
  margin-top: 18px;
}


/* ---------------------------------------------------------------
   STATUS / ERRORS
   --------------------------------------------------------------- */

.connection-status {
  position: fixed;
  right: 15px;
  bottom: 15px;
  padding: 5px 9px;
  border: 1px solid var(--border);
  border-radius: 4px;
  background: rgba(13, 17, 23, 0.92);
  color: var(--muted);
  font-size: 10px;
}

.connection-status.connected {
  color: var(--success);
}

.connection-status.error {
  color: var(--danger);
}

main:has(#screen-home.active) #connection-status {
  display: none;
}

.error-message {
  margin-top: 14px;
  padding: 11px 13px;
  border: 1px solid rgba(230, 107, 107, 0.4);
  border-radius: 5px;
  background: rgba(230, 107, 107, 0.08);
  color: #f19a9a;
  font-size: 13px;
}


/* ---------------------------------------------------------------
   FOOTER
   --------------------------------------------------------------- */

.site-footer {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 22px;
  border-top: 1px solid var(--border);
  color: #697686;
  font-size: 9px;
  font-weight: bold;
  letter-spacing: 2px;
}


/* ---------------------------------------------------------------
   UTILITIES
   --------------------------------------------------------------- */

.hidden {
  display: none !important;
}


/* ---------------------------------------------------------------
   MOBILE
   --------------------------------------------------------------- */

@media (max-width: 650px) {

  .site-header {
    padding: 0 16px;
  }

  .game-shell {
    width: min(
      calc(100% - 20px),
      var(--max-width)
    );

    padding-top: 25px;
  }

  .game-header {
    align-items: center;
  }

  .game-header h1 {
    font-size: 34px;
  }

  .home-actions {
    grid-template-columns: 1fr;
  }

  .screen-heading,
  .round-header {
    flex-direction: column;
  }

  .room-code {
    text-align: left;
  }

  .timer {
    align-self: flex-start;
  }

  .lobby-actions,
  .final-actions {
    flex-direction: column;
  }

  .lobby-actions button,
  .final-actions button {
    width: 100%;
  }

  .winner-card {
    padding: 22px 16px;
  }

  .winner-card blockquote {
    font-size: 21px;
  }

  .story-text {
    font-size: 16px;
  }

  .final-story {
    font-size: 17px;
  }

  .connection-status {
    bottom: 8px;
    right: 8px;
  }
}


/* ---------------------------------------------------------------
   PANEL TRANSITIONS
   --------------------------------------------------------------- */

#writing-input-panel:not(.hidden),
#writing-submitted:not(.hidden),
#voting-input-panel:not(.hidden),
#voting-submitted:not(.hidden) {
  animation: panel-fade-in 0.25s ease-out;
}

@keyframes panel-fade-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@media (prefers-reduced-motion: reduce) {
  #writing-input-panel:not(.hidden),
  #writing-submitted:not(.hidden),
  #voting-input-panel:not(.hidden),
  #voting-submitted:not(.hidden) {
    animation: none;
  }
}
