/* ==========================================================================
   SEA QUEST: ISLAND TYCOON - EDUPLAY VISUAL IDENTITY (MOBILE OPTIMIZED)
   ========================================================================== */

   :root {
    /* Color Palette */
    --bg-dark: #0b132b;
    --bg-navy: #1c2541;
    --panel-glass: rgba(28, 37, 65, 0.75);
    --border-glass: rgba(255, 255, 255, 0.15);
    
    --primary-green: #58CC02;
    --primary-green-hover: #46a302;
    --accent-blue: #1CB0F6;
    --accent-blue-hover: #0093d9;
    --highlight-orange: #FF9600;
    --highlight-orange-hover: #e08400;
    
    --text-white: #ffffff;
    --text-muted: #a0aec0;
    --danger-red: #ff4b4b;
  
    --shadow-soft: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
  
    --font-main: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  }
  
  * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
  }
  
  body, html {
    width: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    background-color: var(--bg-dark);
    font-family: var(--font-main);
    color: var(--text-white);
    overflow-x: hidden;
  }
  
  #app-container {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
  }
  
  /* Glassmorphism utility */
  .glass {
    background: var(--panel-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    box-shadow: var(--shadow-soft);
  }
  
  .glass-modal {
    background: rgba(11, 19, 43, 0.85);
    backdrop-filter: blur(8px);
  }
  
  /* NAVBAR */
  .navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 14px;
    min-height: 56px;
    z-index: 10;
    gap: 8px;
  }
  
  .logo-area {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
  }
  
  .logo-icon {
    font-size: 24px;
    flex-shrink: 0;
  }
  
  .logo-title {
    min-width: 0;
  }
  
  .logo-title h1 {
    font-size: 16px;
    font-weight: 800;
    letter-spacing: 0.5px;
    color: var(--accent-blue);
    line-height: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .logo-title .subtitle {
    font-size: 9px;
    letter-spacing: 1.5px;
    color: var(--highlight-orange);
    font-weight: 700;
    white-space: nowrap;
  }
  
  .header-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }
  
  .game-timer {
    background: rgba(0,0,0,0.4);
    padding: 4px 8px;
    border-radius: 20px;
    font-weight: bold;
    font-size: 12px;
    border: 1px solid var(--border-glass);
  }
  
  /* BUTTONS */
  .btn {
    border: none;
    outline: none;
    padding: 8px 14px;
    border-radius: var(--radius-md);
    font-weight: 700;
    font-size: 13px;
    cursor: pointer;
    transition: transform 0.1s ease, background 0.2s ease, box-shadow 0.2s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    color: #fff;
    min-height: 40px;
  }
  
  .btn:active {
    transform: scale(0.96);
  }
  
  .btn-primary {
    background: var(--primary-green);
    box-shadow: 0 4px 0 #3b8701;
  }
  .btn-primary:hover {
    background: var(--primary-green-hover);
  }
  
  .btn-secondary {
    background: var(--accent-blue);
    box-shadow: 0 4px 0 #0077b3;
  }
  .btn-secondary:hover {
    background: var(--accent-blue-hover);
  }
  
  .btn-accent {
    background: var(--highlight-orange);
    box-shadow: 0 4px 0 #b36b00;
  }
  .btn-accent:hover {
    background: var(--highlight-orange-hover);
  }
  
  .btn-large {
    padding: 12px 20px;
    font-size: 15px;
  }
  
  .block {
    width: 100%;
  }
  
  .close-btn {
    background: transparent;
    border: none;
    color: var(--text-white);
    font-size: 24px;
    cursor: pointer;
  }
  
  /* GAME LAYOUT */
  .game-layout {
    display: grid;
    grid-template-columns: 240px 1fr 240px;
    flex: 1;
    gap: 12px;
    padding: 12px;
    overflow: hidden;
  }
  
  .hud-sidebar {
    display: flex;
    flex-direction: column;
    gap: 8px;
    overflow: hidden;
  }
  
  .panel-header h3 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--accent-blue);
    padding: 4px 8px;
    border-bottom: 2px solid var(--border-glass);
  }
  
  /* PLAYER CARDS HUD */
  .players-hud-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    overflow-y: auto;
  }
  
  .player-card-hud {
    padding: 10px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.05);
    border: 2px solid transparent;
    transition: all 0.3s ease;
  }
  
  .player-card-hud.active-turn {
    border-color: var(--primary-green);
    background: rgba(88, 204, 2, 0.15);
  }
  
  .player-hud-header {
    display: flex;
    align-items: center;
    gap: 8px;
  }
  
  .player-avatar {
    font-size: 18px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.3);
    flex-shrink: 0;
  }
  
  .player-info h4 {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  
  .player-info .badge {
    font-size: 9px;
  }
  
  .player-stats {
    display: flex;
    justify-content: space-between;
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted);
  }
  
  .player-stats .kc-val {
    color: var(--highlight-orange);
    font-weight: bold;
  }
  
  /* BOARD CONTAINER */
  .board-container {
    position: relative;
    border-radius: var(--radius-lg);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(11, 19, 43, 0.5);
    width: 100%;
    height: 100%;
    touch-action: manipulation;
  }
  
  #board-canvas {
    width: 100%;
    height: 100%;
    display: block;
  }
  
  .dice-overlay {
    position: absolute;
    bottom: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    z-index: 5;
  }
  
  .dice-box {
    width: 48px;
    height: 48px;
    background: #fff;
    color: #000;
    font-size: 24px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 0 #ccc;
  }
  
  .dice-box.rolling {
    animation: spin 0.4s infinite linear;
  }
  
  @keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
  }
  
  /* LOG PANEL */
  .activity-log-box {
    flex: 1;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    padding: 8px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 11px;
  }
  
  .log-entry {
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    background: rgba(255, 255, 255, 0.05);
    line-height: 1.3;
  }
  
  .log-entry.system { border-left: 3px solid var(--accent-blue); }
  .log-entry.gain { border-left: 3px solid var(--primary-green); }
  .log-entry.loss { border-left: 3px solid var(--danger-red); }
  
  /* MODALS */
  .screen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
    padding: 12px;
  }
  
  .screen-overlay.active {
    opacity: 1;
    pointer-events: auto;
  }
  
  .modal-card {
    width: 100%;
    max-width: 500px;
    padding: 18px;
    border-radius: var(--radius-lg);
    max-height: 90vh;
    max-height: 90dvh;
    overflow-y: auto;
  }
  
  .badge {
    display: inline-block;
    padding: 3px 6px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
  }
  
  .badge-blue { background: var(--accent-blue); color: #fff; }
  .badge-green { background: var(--primary-green); color: #fff; }
  .badge-orange { background: var(--highlight-orange); color: #fff; }
  .badge-dark { background: rgba(0,0,0,0.5); color: #fff; }
  
  .question-card { max-width: 550px; }
  .question-header { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
  .question-title { font-size: 16px; margin-bottom: 14px; line-height: 1.4; }
  
  .choices-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
  }
  
  .choice-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--border-glass);
    padding: 10px;
    border-radius: var(--radius-md);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    min-height: 44px;
  }
  
  .choice-btn.correct { background: var(--primary-green) !important; }
  .choice-btn.wrong { background: var(--danger-red) !important; }
  
  .feedback-panel {
    margin-top: 10px;
    padding: 10px;
    border-radius: var(--radius-md);
    background: rgba(0, 0, 0, 0.3);
  }
  
  .event-card { text-align: center; }
  .event-icon-box { font-size: 44px; margin: 8px 0; }
  .reward-tag { font-size: 16px; font-weight: bold; color: var(--highlight-orange); margin: 8px 0; }
  
  .form-group { margin-bottom: 12px; }
  .form-group label { display: block; font-size: 12px; font-weight: bold; margin-bottom: 4px; color: var(--text-muted); }
  
  .input-control {
    width: 100%;
    padding: 8px 10px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-glass);
    background: rgba(0, 0, 0, 0.3);
    color: #fff;
    font-size: 13px;
    outline: none;
    min-height: 40px;
  }
  
  .players-config-grid { display: flex; flex-direction: column; gap: 8px; }
  .player-config-item { display: flex; gap: 6px; align-items: center; }
  .player-config-item select, .player-config-item input { flex: 1; }
  
  .table-wrapper { margin-top: 10px; max-height: 300px; overflow-y: auto; }
  .leaderboard-table { width: 100%; border-collapse: collapse; font-size: 12px; text-align: left; }
  .leaderboard-table th, .leaderboard-table td { padding: 6px 8px; border-bottom: 1px solid var(--border-glass); }
  
  .hidden { display: none !important; }
  
  /* ==========================================================================
     MOBILE & TABLET RESPONSIVE BREAKPOINTS
     ========================================================================== */
  
  /* Tablets (Max Width: 960px) */
  @media (max-width: 960px) {
    .game-layout {
      grid-template-columns: 200px 1fr 200px;
      gap: 8px;
      padding: 8px;
    }
  }
  
  /* Phones & Mobile Viewports (Max Width: 768px) */
  @media (max-width: 768px) {
    body, html {
      overflow-y: auto;
    }
  
    #app-container {
      height: auto;
      min-height: 100dvh;
    }
  
    .game-layout {
      display: flex;
      flex-direction: column;
      padding: 8px;
      gap: 10px;
      height: auto;
      overflow: visible;
    }
  
    /* Dynamic HUD ordering for mobile */
    .left-hud { order: 1; }
    .board-container { order: 2; aspect-ratio: 1 / 1; width: 100%; max-height: 65vh; }
    .right-hud { order: 3; max-height: 180px; }
  
    /* Horizontal scrollable player cards on mobile */
    .players-hud-container {
      flex-direction: row;
      overflow-x: auto;
      padding-bottom: 4px;
    }
  
    .player-card-hud {
      min-width: 140px;
      flex-shrink: 0;
    }
  
    .logo-title .subtitle { display: none; }
    .choices-grid { grid-template-columns: 1fr; }
  }
  
  /* Extra Small Mobile Devices (Max Width: 480px) */
  @media (max-width: 480px) {
    .navbar { padding: 6px 10px; }
    .logo-title h1 { font-size: 14px; }
    .header-controls .btn { padding: 6px 10px; font-size: 12px; }
  
    .player-config-item {
      flex-direction: column;
      align-items: stretch;
    }
  
    .modal-card {
      padding: 14px;
      border-radius: var(--radius-md);
    }
  
    .dice-overlay { bottom: 8px; }
    .dice-box { width: 40px; height: 40px; font-size: 20px; }
  }