* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: #0f1117; color: #e0e0e0;
  min-height: 100vh; display: flex; flex-direction: column; align-items: center;
}

/* ---- Navigation Bar ---- */
.navbar {
  width: 100%; max-width: 900px; padding: 12px 20px;
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: 1px solid #1f2230; margin-bottom: 24px;
}
.navbar .brand { font-size: 18px; font-weight: 700; color: #fff; text-decoration: none; }
.navbar .nav-links { display: flex; gap: 16px; align-items: center; }
.navbar .nav-links a { color: #888; text-decoration: none; font-size: 13px; }
.navbar .nav-links a:hover { color: #fff; }
.navbar .nav-links .user-tag {
  font-size: 12px; background: #1a1d27; padding: 4px 12px; border-radius: 12px; color: #ccc;
}

/* ---- Buttons ---- */
.btn {
  display: inline-block; padding: 14px 40px; font-size: 17px; font-weight: 700; border: none;
  border-radius: 10px; cursor: pointer; transition: all 0.15s;
  min-width: 130px; color: #fff; text-align: center; text-decoration: none;
}
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn.buy { background: #4caf50; }
.btn.buy:hover:not(:disabled) { background: #43a047; }
.btn.sell { background: #f44336; }
.btn.sell:hover:not(:disabled) { background: #e53935; }
.btn.skip { background: #555; }
.btn.skip:hover:not(:disabled) { background: #666; }
.btn.secondary { background: #3f51b5; }
.btn.secondary:hover { background: #3949ab; }
.btn.danger { background: #c62828; }
.btn.danger:hover { background: #b71c1c; }
.btn.outline { background: transparent; border: 1px solid #444; color: #ccc; }
.btn.outline:hover { border-color: #888; color: #fff; }
.btn.small { padding: 8px 20px; font-size: 13px; min-width: auto; }

/* ---- Home Page ---- */
#home { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 100vh; gap: 32px; }
#home h1 { font-size: 36px; color: #fff; }
#home .subtitle { color: #888; font-size: 14px; margin-top: -20px; }
.mode-cards { display: flex; gap: 24px; flex-wrap: wrap; justify-content: center; }
.mode-card {
  background: #1a1d27; border: 1px solid #2a2d37; border-radius: 16px;
  padding: 32px 40px; cursor: pointer; transition: all 0.2s;
  text-align: center; min-width: 220px;
}
.mode-card:hover { border-color: #4caf50; transform: translateY(-2px); }
.mode-card.locked { opacity: 0.4; cursor: not-allowed; }
.mode-card.locked:hover { border-color: #2a2d37; transform: none; }
.mode-card .icon { font-size: 40px; margin-bottom: 12px; }
.mode-card h3 { font-size: 20px; color: #fff; margin-bottom: 6px; }
.mode-card p { font-size: 13px; color: #888; }
.mode-card .badge {
  display: inline-block; background: #ff9800; color: #000; font-size: 11px;
  padding: 2px 8px; border-radius: 10px; margin-top: 8px; font-weight: 600;
}

/* ---- Game Page ---- */
.game-container { display: flex; flex-direction: column; align-items: center; width: 100%; }
.header {
  width: 100%; max-width: 900px; padding: 16px 20px;
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 12px;
}
.header .symbol-info { display: flex; align-items: baseline; gap: 8px; }
.header .symbol-info .name { font-size: 22px; font-weight: 700; color: #fff; }
.header .symbol-info .code { font-size: 13px; color: #888; }
.stats { display: flex; gap: 20px; flex-wrap: wrap; }
.stat { text-align: center; }
.stat .label { font-size: 11px; color: #888; text-transform: uppercase; letter-spacing: 1px; }
.stat .value { font-size: 17px; font-weight: 600; color: #fff; }
.stat .value.positive { color: #4caf50; }
.stat .value.negative { color: #f44336; }

.chart-container {
  width: 100%; max-width: 900px; height: 420px;
  background: #1a1d27; border-radius: 12px; padding: 16px; margin: 0 20px;
  position: relative;
}
.chart-container canvas { width: 100% !important; height: 100% !important; }

.day-info { text-align: center; font-size: 13px; color: #888; margin-bottom: 4px; }

.actions { display: flex; gap: 14px; margin: 20px; flex-wrap: wrap; justify-content: center; }

.trade-log {
  width: 100%; max-width: 900px; margin: 8px 20px 40px;
  display: flex; flex-wrap: wrap; gap: 6px; min-height: 28px; align-items: center;
}
.trade-tag { font-size: 12px; padding: 4px 10px; border-radius: 14px; font-weight: 600; }
.trade-tag.buy { background: #1b5e20; color: #a5d6a7; }
.trade-tag.sell { background: #b71c1c; color: #ef9a9a; }
.trade-tag.hold { background: #333; color: #aaa; }
.trade-empty { font-size: 12px; color: #555; }

/* ---- Result Overlay ---- */
.overlay {
  display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.75);
  z-index: 100; justify-content: center; align-items: center;
}
.overlay.show { display: flex; }
.result-card {
  background: #1a1d27; border-radius: 16px; padding: 32px; max-width: 480px;
  width: 90%; text-align: center;
}
.result-card h2 { font-size: 28px; margin-bottom: 8px; }
.result-card h2.win { color: #4caf50; } .result-card h2.lose { color: #f44336; } .result-card h2.even { color: #ff9800; }
.result-card .stock-name { font-size: 14px; color: #888; margin-bottom: 20px; }
.result-row {
  display: flex; justify-content: space-between; padding: 10px 0;
  border-bottom: 1px solid #2a2d37; font-size: 15px;
}
.result-row .val.positive { color: #4caf50; } .result-row .val.negative { color: #f44336; }
.result-card .btn-group { display: flex; gap: 12px; margin-top: 24px; justify-content: center; flex-wrap: wrap; }

/* ---- Auth Pages ---- */
.auth-container {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; gap: 24px;
}
.auth-card {
  background: #1a1d27; border: 1px solid #2a2d37; border-radius: 16px;
  padding: 32px; width: 100%; max-width: 400px;
}
.auth-card h2 { font-size: 24px; color: #fff; margin-bottom: 24px; text-align: center; }
.auth-card .tab-row { display: flex; margin-bottom: 24px; }
.auth-card .tab-row button {
  flex: 1; padding: 10px; background: transparent; border: none; color: #888;
  font-size: 14px; cursor: pointer; border-bottom: 2px solid #2a2d37;
}
.auth-card .tab-row button.active { color: #4caf50; border-bottom-color: #4caf50; }
.form-group { margin-bottom: 16px; }
.form-group label { display: block; font-size: 12px; color: #888; margin-bottom: 6px; }
.form-group input {
  width: 100%; padding: 10px 14px; background: #0f1117; border: 1px solid #2a2d37;
  border-radius: 8px; color: #e0e0e0; font-size: 15px; outline: none;
}
.form-group input:focus { border-color: #4caf50; }
.form-group .code-row { display: flex; gap: 8px; }
.form-group .code-row input { flex: 1; }
.form-group .hint { font-size: 11px; color: #666; margin-top: 4px; }
.form-msg { font-size: 13px; text-align: center; margin-top: 8px; min-height: 20px; }
.form-msg.error { color: #f44336; }
.form-msg.success { color: #4caf50; }

/* ---- Profile Page ---- */
.profile-container { width: 100%; max-width: 900px; padding: 0 20px; }
.profile-header {
  display: flex; gap: 24px; align-items: center; padding: 24px 0;
  border-bottom: 1px solid #1f2230; margin-bottom: 24px; flex-wrap: wrap;
}
.profile-header .avatar {
  width: 64px; height: 64px; border-radius: 50%; background: #1a1d27;
  display: flex; align-items: center; justify-content: center;
  font-size: 28px; color: #888; flex-shrink: 0;
}
.profile-header .info h2 { font-size: 22px; color: #fff; }
.profile-header .info .meta { font-size: 12px; color: #888; margin-top: 4px; }
.stats-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px; margin-bottom: 32px;
}
.stat-card {
  background: #1a1d27; border-radius: 10px; padding: 16px; text-align: center;
}
.stat-card .stat-value { font-size: 24px; font-weight: 700; color: #fff; }
.stat-card .stat-label { font-size: 12px; color: #888; margin-top: 4px; }
.stat-card .stat-value.win { color: #4caf50; } .stat-card .stat-value.loss { color: #f44336; }

.game-list { margin-bottom: 40px; }
.game-list h3 { font-size: 18px; color: #fff; margin-bottom: 12px; }
.game-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; background: #1a1d27; border-radius: 8px;
  margin-bottom: 8px; flex-wrap: wrap; gap: 8px;
}
.game-row .gr-stock { font-weight: 600; color: #fff; min-width: 100px; }
.game-row .gr-date { font-size: 12px; color: #888; }
.game-row .gr-pnl { font-weight: 600; font-size: 15px; }
.game-row .gr-pnl.win { color: #4caf50; } .game-row .gr-pnl.loss { color: #f44336; }
.game-row .gr-trades { font-size: 12px; color: #888; }
.pagination { display: flex; gap: 8px; justify-content: center; margin-top: 12px; }

/* ---- Unified Chart Panel ---- */
.chart-panel {
  width: 100%; max-width: 900px; margin: 0 20px;
  background: #1a1d27; border-radius: 10px; overflow: hidden;
}
.chart-main { width: 100%; height: 240px; padding: 8px 12px 0; }
.chart-main canvas { width: 100% !important; height: 100% !important; }
.chart-divider { width: 100%; height: 1px; background: #2a2d37; margin: 0 12px; width: calc(100% - 24px); }
.chart-sub { width: 100%; height: 115px; padding: 4px 12px 8px; position: relative; }
.chart-sub canvas { width: 100% !important; height: calc(100% - 24px) !important; }
.ind-selector {
  display: flex; gap: 4px; height: 24px; align-items: center; flex-wrap: wrap;
}
.ind-tab {
  background: transparent; border: none; color: #666; font-size: 11px;
  padding: 2px 10px; cursor: pointer; border-radius: 3px; transition: all 0.15s;
}
.ind-tab:hover { color: #aaa; }
.ind-tab.active { background: #2a2d37; color: #4caf50; font-weight: 600; }

/* ---- Loading & Spinner ---- */
.waiting {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 100vh; gap: 16px;
}
.waiting .spinner {
  width: 40px; height: 40px; border: 4px solid #2a2d37;
  border-top-color: #4caf50; border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- Toast ---- */
.toast {
  position: fixed; top: 20px; left: 50%; transform: translateX(-50%);
  background: #333; color: #fff; padding: 10px 24px; border-radius: 20px;
  font-size: 13px; z-index: 200; animation: fadeInOut 3s ease;
}
.toast.error { background: #b71c1c; }
.toast.success { background: #2e7d32; }
@keyframes fadeInOut {
  0% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  10% { opacity: 1; transform: translateX(-50%) translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; }
}

.navbar .brand img { vertical-align: middle; }
