:root {
  --bg: #020617;
  --panel: #0f172a;
  --panel-2: #111827;
  --text: #e5eefc;
  --muted: #9fb2d7;
  --accent: #38bdf8;
  --accent-2: #22c55e;
  --danger: #ef4444;
  --border: rgba(148, 163, 184, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background: radial-gradient(circle at top, #0f172a 0%, #020617 60%);
  color: var(--text);
}

button,
input {
  font: inherit;
}

.page-shell {
  max-width: 1360px;
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(1.8rem, 2.5vw, 2.8rem);
}

.subtitle {
  margin: 4px 0 0;
  color: var(--muted);
}

.today-badge {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.35);
}

/* ---- Index landing layout ---- */
.landing-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 380px);
  gap: 16px;
  align-items: start;
}

.hero-panel {
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.hero-title {
  margin: 0;
  font-size: clamp(1.4rem, 3vw, 2rem);
  color: var(--accent);
}

.hero-sub {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
}

.name-form {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.name-form input {
  flex: 1;
  min-width: 160px;
  background: #0f172a;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 1rem;
  outline: none;
}

.name-form input:focus {
  border-color: rgba(56, 189, 248, 0.5);
}

button.large {
  padding: 12px 28px;
  font-size: 1rem;
}

/* ---- Back link ---- */
.back-link {
  display: inline-block;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  margin-bottom: 4px;
}

.back-link:hover {
  color: var(--accent);
}

/* ---- Game shell (game.php) ---- */
.game-shell main {
  display: block;
}

.game-shell .game-panel {
  max-width: 560px;
  margin: 0 auto;
}

/* ---- Mission Report Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}

.modal-card {
  width: 100%;
  max-width: 480px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-title {
  margin: 0;
  font-size: 1.2rem;
  color: var(--accent);
}

.modal-summary {
  margin: 0;
  line-height: 1.75;
  font-size: 0.95rem;
}

.modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

/* ---- Post-submit back button ---- */
.post-submit {
  margin-top: 12px;
}

.btn-home {
  display: inline-block;
  padding: 10px 20px;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.5);
  color: var(--accent);
  border-radius: 12px;
  text-decoration: none;
  font-weight: 600;
  font-size: 0.95rem;
  transition: background 0.15s ease;
}

.btn-home:hover {
  background: rgba(56, 189, 248, 0.25);
}

/* ---- Responsive ---- */
@media (max-width: 700px) {
  .landing-layout {
    grid-template-columns: 1fr;
  }
}

.card {
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.96), rgba(2, 6, 23, 0.96));
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.28);
}

.game-panel,
.sidebar {
  padding: 16px;
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.hud-item {
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
}

.hud-item .label {
  display: block;
  font-size: 0.85rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.action-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

button {
  border: 1px solid var(--border);
  background: #162033;
  color: var(--text);
  padding: 11px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(56, 189, 248, 0.45);
}

button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

button.primary {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.5);
  color: var(--accent);
  font-weight: 600;
}

button.primary:hover:not(:disabled) {
  background: rgba(56, 189, 248, 0.25);
}

button.active {
  background: rgba(56, 189, 248, 0.2);
  border-color: var(--accent);
  color: var(--accent);
}

/* Energy bar */
.energy-bar-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  color: var(--muted);
}

.energy-bar {
  flex: 1;
  height: 10px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid var(--border);
  border-radius: 999px;
  overflow: hidden;
}

.energy-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #0ea5e9, #38bdf8);
  border-radius: 999px;
  transition: width 0.1s linear;
}

/* Canvas */
#gameCanvas {
  cursor: crosshair;
  display: block;
  max-width: 100%;
  border-radius: 14px;
}


.share-box {
  margin: 10px 0 0;
  padding: 8px 12px;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.2);
  border-radius: 10px;
  font-size: 0.9rem;
  display: none;
}

.share-box:not(:empty) {
  display: block;
}

.submit-row {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.submit-row input {
  flex: 1;
  background: #0f172a;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 12px;
  outline: none;
}

.submit-row input:focus {
  border-color: rgba(56, 189, 248, 0.5);
}

/* Leaderboard */
.leaderboard-list {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.leader-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
}

/* Sidebar */
.sidebar section + section {
  margin-top: 20px;
}

.sidebar h2 {
  margin: 0 0 10px;
  font-size: 1rem;
  color: var(--accent);
}

.sidebar ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.7;
}