    :root {
      --gold: #d4af37;
      --gold-dark: #b8960c;
      --parchment: #f4e4bc;
      --parchment-dark: #e8d5a3;
      --ink: #2c1810;
      --ink-light: #4a3728;
      --red: #8b0000;
      --green: #228b22;
    }

    * {
      box-sizing: border-box;
      margin: 0;
      padding: 0;
    }

    body {
      font-family: 'Lora', Georgia, serif;
      background: linear-gradient(135deg, #1a0f0a 0%, #2c1810 50%, #1a0f0a 100%);
      min-height: 100vh;
      color: var(--parchment);
      /* Mobile-optimized: prevent bounce scrolling */
      overscroll-behavior: none;
    }

    .container {
      max-width: 600px;
      margin: 0 auto;
      padding: 15px;
      min-height: 100vh;
      display: flex;
      flex-direction: column;
    }

    /* Mobile frame decoration */
    .mobile-frame {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      border: 8px solid transparent;
      border-image: linear-gradient(135deg, var(--gold), var(--gold-dark), var(--gold)) 1;
      pointer-events: none;
      z-index: 100;
    }

    h1, h2, h3 {
      font-family: 'Cinzel Decorative', 'Cinzel', serif;
      color: var(--gold);
      text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    }

    .title {
      text-align: center;
      font-family: 'Cinzel Decorative', serif;
      font-size: 1.8rem;
      margin-bottom: 5px;
      letter-spacing: 2px;
    }

    /* Hide header during game */
    .game-active .title,
    .game-active .subtitle {
      display: none;
    }

    .subtitle {
      text-align: center;
      font-style: italic;
      color: var(--parchment-dark);
      margin-bottom: 15px;
      font-size: 0.9rem;
    }

    /* Screens */
    .screen {
      display: none;
      flex: 1;
      flex-direction: column;
    }

    .screen.active {
      display: flex;
    }

    /* Welcome Screen */
    #welcome-screen {
      justify-content: center;
      align-items: center;
      text-align: center;
    }

    .menu-buttons {
      display: flex;
      flex-direction: column;
      gap: 15px;
      margin-top: 30px;
    }

    .btn {
      font-family: 'Cinzel', serif;
      font-size: 1.1rem;
      padding: 15px 40px;
      border: 2px solid var(--gold);
      background: linear-gradient(180deg, rgba(212,175,55,0.2) 0%, rgba(212,175,55,0.1) 100%);
      color: var(--gold);
      cursor: pointer;
      transition: all 0.3s ease;
      text-transform: uppercase;
      letter-spacing: 2px;
    }

    .btn:hover {
      background: linear-gradient(180deg, rgba(212,175,55,0.4) 0%, rgba(212,175,55,0.2) 100%);
      transform: scale(1.02);
      box-shadow: 0 0 20px rgba(212,175,55,0.3);
    }

    .btn:disabled {
      opacity: 0.5;
      cursor: not-allowed;
    }

    .btn-primary {
      background: linear-gradient(180deg, var(--gold) 0%, var(--gold-dark) 100%);
      color: var(--ink);
    }

    .btn-primary:hover {
      background: linear-gradient(180deg, #e8c252 0%, var(--gold) 100%);
    }

    /* Join Screen */
    #join-screen {
      justify-content: center;
      align-items: center;
    }

    .input-group {
      margin: 20px 0;
      width: 100%;
      max-width: 300px;
    }

    .input-group label {
      display: block;
      margin-bottom: 8px;
      color: var(--gold);
      font-family: 'Cinzel', serif;
    }

    .input-group input {
      width: 100%;
      padding: 12px 15px;
      font-size: 1.2rem;
      font-family: 'Crimson Text', serif;
      border: 2px solid var(--gold);
      background: rgba(244, 228, 188, 0.1);
      color: var(--parchment);
      text-align: center;
    }

    .input-group input#room-code-input {
      text-transform: uppercase;
      letter-spacing: 3px;
    }

    .input-group input::placeholder {
      color: rgba(244, 228, 188, 0.5);
      text-transform: none;
      letter-spacing: normal;
    }

    .input-group input:focus {
      outline: none;
      background: rgba(244, 228, 188, 0.15);
      box-shadow: 0 0 10px rgba(212,175,55,0.3);
    }

    /* Lobby Screen */
    #lobby-screen {
      align-items: center;
    }

    .room-code-display {
      background: rgba(0,0,0,0.3);
      border: 3px solid var(--gold);
      padding: 20px 40px;
      margin: 20px 0;
      text-align: center;
    }

    .room-code-display .label {
      font-size: 0.9rem;
      color: var(--parchment-dark);
      margin-bottom: 5px;
    }

    .room-code-display .code {
      font-family: 'Cinzel', serif;
      font-size: 3rem;
      color: var(--gold);
      letter-spacing: 10px;
    }

    .player-list {
      width: 100%;
      max-width: 400px;
      margin: 20px 0;
    }

    .player-list h3 {
      margin-bottom: 15px;
      text-align: center;
    }

    .player-item {
      display: flex;
      align-items: center;
      padding: 10px 15px;
      background: rgba(244, 228, 188, 0.1);
      border-left: 3px solid var(--gold);
      margin-bottom: 8px;
    }

    .player-item .name {
      flex: 1;
    }

    .player-item .host-badge {
      background: var(--gold);
      color: var(--ink);
      padding: 2px 8px;
      font-size: 0.75rem;
      font-family: 'Cinzel', serif;
      text-transform: uppercase;
    }

    .player-item .score {
      margin-left: 10px;
      color: var(--gold);
    }

    /* Game Settings (Host Only) */
    .game-settings-section {
      width: 100%;
      max-width: 500px;
      margin: 20px 0;
      padding: 20px;
      background: rgba(212, 175, 55, 0.1);
      border: 2px solid var(--gold);
    }

    .game-settings-section h3 {
      margin-bottom: 15px;
      text-align: center;
      font-size: 1.2rem;
    }

    .settings-grid {
      display: grid;
      grid-template-columns: 1fr 1fr;
      gap: 15px;
    }

    .setting-item {
      display: flex;
      flex-direction: column;
    }

    .setting-item label {
      font-family: 'Cinzel', serif;
      color: var(--gold);
      margin-bottom: 5px;
      font-size: 0.9rem;
    }

    .setting-item select {
      padding: 8px 12px;
      font-family: 'Crimson Text', serif;
      font-size: 1rem;
      border: 2px solid var(--gold);
      background: #2c1810;
      color: var(--parchment);
      cursor: pointer;
    }

    .setting-item select:focus {
      outline: none;
      background: #3d2518;
      box-shadow: 0 0 10px rgba(212,175,55,0.3);
    }

    .setting-item select option {
      background: #2c1810;
      color: var(--parchment);
      padding: 8px;
    }

    @media (max-width: 600px) {
      .settings-grid {
        grid-template-columns: 1fr;
      }
    }

    /* API Key Input (Host Only) */
    .api-key-section {
      width: 100%;
      max-width: 400px;
      margin: 20px 0;
      padding: 15px;
      background: rgba(139, 0, 0, 0.2);
      border: 1px solid var(--red);
    }

    .api-key-section input {
      width: 100%;
      padding: 10px;
      font-family: monospace;
      font-size: 0.9rem;
      border: 1px solid var(--gold);
      background: rgba(0,0,0,0.3);
      color: var(--parchment);
    }

    .api-key-section .note {
      font-size: 0.8rem;
      color: var(--parchment-dark);
      margin-top: 8px;
      font-style: italic;
    }

    /* Game Screen */
    #game-screen {
      gap: 20px;
    }

    .game-header {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 10px 20px;
      background: rgba(0,0,0,0.3);
      border-bottom: 2px solid var(--gold);
    }

    .round-info {
      font-family: 'Cinzel', serif;
    }

    .timer {
      font-size: 1.5rem;
      font-family: 'Cinzel', serif;
      color: var(--gold);
    }

    .timer.urgent {
      color: var(--red);
      animation: pulse 0.5s ease-in-out infinite;
    }

    @keyframes pulse {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.5; }
    }

    .phase-indicator {
      text-transform: uppercase;
      letter-spacing: 2px;
      font-size: 0.9rem;
    }

    /* Story Display - HIDDEN on player view (story shown on TV display only) */
    .story-container {
      display: none; /* Hidden on mobile player view */
    }

    /* Mobile prompt display - shows what the player needs to do */
    .prompt-display {
      background: linear-gradient(180deg, rgba(244,228,188,0.1) 0%, rgba(244,228,188,0.05) 100%);
      border: 2px solid var(--gold);
      padding: 15px;
      margin-bottom: 15px;
      text-align: center;
    }

    .prompt-display h3 {
      font-size: 1.2rem;
      margin-bottom: 10px;
    }

    .prompt-display .prompt-text {
      font-size: 1rem;
      color: var(--parchment);
      font-style: italic;
    }

    .story-entry {
      margin-bottom: 20px;
      line-height: 1.8;
    }

    .story-entry.narration {
      font-size: 1.1rem;
      color: var(--parchment);
    }

    .story-entry.narration p {
      margin-bottom: 1em;
    }

    .story-entry.narration p:last-child {
      margin-bottom: 0;
    }

    .story-entry.action {
      padding-left: 20px;
      border-left: 3px solid var(--gold);
      color: var(--gold);
      font-style: italic;
    }

    .story-entry .player-name {
      font-family: 'Cinzel', serif;
      font-weight: bold;
      color: var(--gold);
    }

    /* Submission Area */
    .submission-area {
      padding: 20px;
      background: rgba(0,0,0,0.2);
      border-top: 2px solid var(--gold);
    }

    .submission-area textarea {
      width: 100%;
      padding: 15px;
      font-family: 'Crimson Text', serif;
      font-size: 1.1rem;
      border: 2px solid var(--gold);
      background: rgba(244, 228, 188, 0.1);
      color: var(--parchment);
      resize: none;
      min-height: 80px;
    }

    .submission-area textarea:focus {
      outline: none;
      background: rgba(244, 228, 188, 0.15);
    }

    .submission-area .char-count {
      text-align: right;
      font-size: 0.8rem;
      color: var(--parchment-dark);
      margin-top: 5px;
    }

    /* Voting Area */
    .voting-area {
      padding: 20px;
    }

    .voting-option {
      padding: 15px 20px;
      margin-bottom: 10px;
      background: rgba(244, 228, 188, 0.1);
      border: 2px solid transparent;
      cursor: pointer;
      transition: all 0.3s ease;
    }

    .voting-option:hover {
      background: rgba(244, 228, 188, 0.2);
      border-color: var(--gold);
    }

    .voting-option.selected {
      background: rgba(212, 175, 55, 0.2);
      border-color: var(--gold);
    }

    .voting-option.own {
      opacity: 0.5;
      cursor: not-allowed;
    }

    .voting-option .action-text {
      font-size: 1.1rem;
      margin-bottom: 5px;
    }

    .voting-option .vote-count {
      font-size: 0.9rem;
      color: var(--gold);
    }

    /* Reaction Emote Buttons */
    .emote-buttons {
      display: flex;
      gap: 8px;
      margin-top: 10px;
      justify-content: flex-start;
    }

    .emote-btn {
      background: rgba(244, 228, 188, 0.15);
      border: 1px solid var(--gold);
      border-radius: 20px;
      padding: 6px 12px;
      font-size: 1rem;
      cursor: pointer;
      transition: all 0.2s ease;
      display: flex;
      align-items: center;
      gap: 4px;
    }

    .emote-btn:hover {
      background: rgba(212, 175, 55, 0.3);
      transform: scale(1.1);
    }

    .emote-btn.active {
      background: rgba(212, 175, 55, 0.4);
      border-color: var(--gold);
      box-shadow: 0 0 8px rgba(212, 175, 55, 0.5);
    }

    .bonus-points-badge {
      display: inline-block;
      background: linear-gradient(135deg, #4CAF50, #2E7D32);
      color: white;
      padding: 2px 8px;
      border-radius: 10px;
      font-size: 0.75rem;
      font-weight: bold;
      margin-left: 8px;
    }

    .emote-btn .emote-count {
      font-size: 0.75rem;
      color: var(--parchment-dark);
      min-width: 14px;
    }

    /* Results / End Screen */
    .results-container {
      text-align: center;
      padding: 40px 20px;
    }

    .winner-announcement {
      font-size: 1.5rem;
      margin: 20px 0;
    }

    .final-scores {
      margin: 30px auto;
      max-width: 300px;
    }

    .final-scores .player-score {
      display: flex;
      justify-content: space-between;
      padding: 10px 15px;
      background: rgba(244, 228, 188, 0.1);
      margin-bottom: 5px;
    }

    /* Round Winners Display */
    .round-winners {
      margin: 30px auto;
      max-width: 500px;
      text-align: left;
    }

    .round-winners h3 {
      text-align: center;
      margin-bottom: 15px;
    }

    .round-winner-item {
      padding: 12px 15px;
      background: rgba(244, 228, 188, 0.1);
      border-left: 3px solid var(--gold);
      margin-bottom: 10px;
    }

    .round-winner-item .round-label {
      font-family: 'Cinzel', serif;
      color: var(--gold);
      font-size: 0.85rem;
      margin-bottom: 5px;
    }

    .round-winner-item .winner-name {
      color: var(--gold);
      font-weight: bold;
    }

    .round-winner-item .winning-action {
      font-style: italic;
      color: var(--parchment-dark);
      margin-top: 5px;
    }

    /* Quest Selection Screen */
    .quest-selection-container {
      text-align: center;
      padding: 20px;
    }

    .bulletin-board {
      background: linear-gradient(180deg, #8B4513 0%, #654321 100%);
      border: 8px solid #4a3728;
      border-radius: 5px;
      padding: 30px;
      max-width: 600px;
      margin: 20px auto;
      box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    }

    .bulletin-board h3 {
      font-family: 'Cinzel', serif;
      color: var(--parchment);
      margin-bottom: 20px;
      text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
    }

    .quest-notice {
      background: var(--parchment);
      color: var(--ink);
      padding: 20px;
      margin: 15px 0;
      transform: rotate(-1deg);
      box-shadow: 3px 3px 10px rgba(0,0,0,0.3);
      cursor: pointer;
      transition: all 0.3s ease;
      border: 1px solid #c9b896;
    }

    .quest-notice:nth-child(2) {
      transform: rotate(1deg);
    }

    .quest-notice:nth-child(3) {
      transform: rotate(-0.5deg);
    }

    .quest-notice:hover {
      transform: scale(1.02) rotate(0deg);
      box-shadow: 5px 5px 15px rgba(0,0,0,0.4);
    }

    .quest-notice.selected {
      background: #f0e6c8;
      border: 3px solid var(--gold);
      transform: scale(1.02) rotate(0deg);
    }

    .quest-notice .quest-title {
      font-family: 'Cinzel', serif;
      font-size: 1.2rem;
      color: var(--ink);
      margin-bottom: 5px;
    }

    .quest-notice .vote-count {
      font-size: 0.85rem;
      color: var(--ink-light);
      margin-top: 10px;
    }

    .quest-loading {
      color: var(--parchment);
      font-style: italic;
    }

    /* Responsive */
    @media (max-width: 600px) {
      .title {
        font-size: 1.8rem;
      }

      .room-code-display .code {
        font-size: 2rem;
        letter-spacing: 5px;
      }

      .btn {
        padding: 12px 25px;
        font-size: 1rem;
      }
    }

    /* Fantasy loading animation - rolling D20 */
    .loading {
      display: inline-block;
      width: 24px;
      height: 24px;
      margin-left: 10px;
      vertical-align: middle;
      position: relative;
    }
    
    .loading::before {
      content: "\2726"; /* Four-pointed star / diamond */
      font-size: 24px;
      color: var(--gold);
      position: absolute;
      animation: dice-roll 1.5s ease-in-out infinite;
      text-shadow: 0 0 8px rgba(212, 175, 55, 0.6);
    }
    
    @keyframes dice-roll {
      0% { transform: rotate(0deg) scale(1); opacity: 1; }
      25% { transform: rotate(90deg) scale(1.1); opacity: 0.8; }
      50% { transform: rotate(180deg) scale(1); opacity: 1; }
      75% { transform: rotate(270deg) scale(1.1); opacity: 0.8; }
      100% { transform: rotate(360deg) scale(1); opacity: 1; }
    }
    
    /* Larger fantasy loading for main areas */
    .loading-large {
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 15px;
      padding: 20px;
    }
    
    .loading-large .dice-container {
      width: 60px;
      height: 60px;
      position: relative;
    }
    
    .loading-large .dice-container::before {
      content: "\2726";
      font-size: 50px;
      color: var(--gold);
      position: absolute;
      animation: dice-roll 1.5s ease-in-out infinite;
      text-shadow: 0 0 15px rgba(212, 175, 55, 0.8);
    }
    
    .loading-large .dice-container::after {
      content: "\2726";
      font-size: 50px;
      color: var(--gold);
      position: absolute;
      animation: dice-roll 1.5s ease-in-out infinite reverse;
      opacity: 0.3;
      text-shadow: 0 0 20px rgba(212, 175, 55, 0.4);
    }
    
    .loading-text {
      font-family: 'Cinzel', serif;
      color: var(--gold);
      font-size: 1.1rem;
      animation: pulse-text 2s ease-in-out infinite;
    }
    
    @keyframes pulse-text {
      0%, 100% { opacity: 1; }
      50% { opacity: 0.6; }
    }

    /* Hidden utility */
    .hidden {
      display: none !important;
    }
