:root {
  --bg: #09121f;
  --bg-soft: #0f1a2b;
  --panel: rgba(17, 28, 44, 0.88);
  --line: rgba(146, 180, 255, 0.22);
  --text: #f5f8ff;
  --muted: #a9b8d3;
  --primary: #4db2ff;
  --primary-strong: #2196f3;
  --danger: #ff6b6b;
  --success: #78e08f;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at top, rgba(40, 83, 170, 0.26), transparent 35%),
    linear-gradient(180deg, #09121f 0%, #071018 100%);
  color: var(--text);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  overscroll-behavior-y: auto;
  overscroll-behavior-x: none;
}

body {
  touch-action: manipulation;
}

body.game-scroll-locked {
  overflow: hidden;
}

button {
  font: inherit;
}

.page {
  width: min(1280px, calc(100% - 24px));
  margin: 24px auto 40px;
}

.hero {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: end;
  margin-bottom: 20px;
  padding: 22px;
  background: linear-gradient(180deg, rgba(15, 26, 43, 0.95), rgba(12, 21, 34, 0.88));
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--primary);
  font-size: 0.92rem;
  letter-spacing: 0.08em;
}

.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.1rem);
}

.lead {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.7;
}

.hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary,
.secondary,
.touch-btn {
  border: 0;
  border-radius: 16px;
  padding: 12px 18px;
  cursor: pointer;
  transition: transform 0.12s ease, opacity 0.12s ease, background 0.12s ease;
}

.primary {
  background: linear-gradient(180deg, #5cc0ff, #1e98f6);
  color: #fff;
  font-weight: 700;
}

.secondary,
.touch-btn {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid rgba(255,255,255,0.08);
}

.primary:hover,
.secondary:hover,
.touch-btn:hover {
  transform: translateY(-1px);
}

.primary:active,
.secondary:active,
.touch-btn:active {
  transform: translateY(1px);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.9fr) minmax(260px, 0.9fr);
  gap: 18px;
}

.game-panel,
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.game-panel {
  padding: 16px;
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.hud-item {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.06);
}

.hud-item span {
  display: block;
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 6px;
}

.hud-item strong {
  font-size: 1.15rem;
}

.game-shell {
  position: relative;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.08);
  background: #050b14;
  touch-action: auto;
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 9;
  touch-action: auto;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(3, 8, 15, 0.52);
  backdrop-filter: blur(2px);
}

.overlay.hidden {
  display: none;
}

.overlay-card {
  width: min(92%, 420px);
  padding: 22px;
  text-align: center;
  border-radius: 20px;
  background: rgba(11, 19, 32, 0.95);
  border: 1px solid rgba(255,255,255,0.09);
}

.overlay-card h2 {
  margin: 0 0 10px;
}

.overlay-card p {
  margin: 0;
  color: var(--muted);
  line-height: 1.7;
}

.touch-controls {
  display: none;
  gap: 12px;
  margin-top: 14px;
  padding: 12px;
  border-radius: 20px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.06);
  touch-action: auto;
}

.mobile-hint {
  color: var(--muted);
  font-size: 0.9rem;
}

.mobile-controls-row {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
}

.swipe-guide {
  min-height: 132px;
  flex: 1;
  padding: 16px;
  border-radius: 18px;
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.09);
  display: grid;
  align-content: center;
  gap: 8px;
}

.swipe-guide-title {
  font-weight: 800;
  color: #dff4ff;
}

.swipe-guide-text {
  color: var(--muted);
  line-height: 1.7;
  font-size: 0.95rem;
}

.mobile-touch-layer {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  touch-action: none;
}

.mobile-touch-zone {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: flex-end;
  padding: 16px;
}

.left-zone {
  left: 0;
  width: 60%;
  justify-content: flex-start;
}

.right-zone {
  right: 0;
  width: 40%;
  justify-content: flex-end;
}

.touch-zone-label {
  padding: 8px 10px;
  border-radius: 999px;
  font-size: 0.78rem;
  color: rgba(255,255,255,0.82);
  background: rgba(5, 11, 20, 0.35);
  border: 1px solid rgba(255,255,255,0.09);
  backdrop-filter: blur(2px);
}

.swipe-pad {
  position: absolute;
  width: 120px;
  height: 120px;
  margin-left: -60px;
  margin-top: -60px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.15);
  background: radial-gradient(circle, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
  box-shadow: inset 0 8px 18px rgba(255,255,255,0.03);
  pointer-events: none;
}

.swipe-pad-knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 52px;
  height: 52px;
  margin-left: -26px;
  margin-top: -26px;
  border-radius: 50%;
  background: linear-gradient(180deg, #82d2ff, #2798f3);
  box-shadow: 0 10px 24px rgba(0,0,0,0.35);
}

.action-buttons {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  justify-items: end;
  flex: 1;
}

.touch-btn {
  min-width: 92px;
  min-height: 92px;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.attack-btn {
  min-width: 140px;
  min-height: 140px;
  font-weight: 800;
  font-size: 1.1rem;
  border-radius: 999px;
  background: linear-gradient(180deg, #ff8e72, #ff5e57);
}

.skill-btn {
  min-width: 140px;
  min-height: 58px;
  font-weight: 700;
  border-radius: 999px;
}

.side-panel {
  display: grid;
  gap: 18px;
  align-content: start;
}

.card {
  padding: 18px;
}

.card h2 {
  margin-top: 0;
  font-size: 1.1rem;
}

.card ul {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.8;
}

.card code {
  font-family: Consolas, Monaco, monospace;
  color: #aee1ff;
}

@media (max-width: 980px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 768px) {
  .page {
    width: min(100%, calc(100% - 12px));
    margin: 12px auto 28px;
  }

  .hero {
    flex-direction: column;
    align-items: stretch;
    padding: 16px;
    border-radius: 18px;
  }

  .lead {
    line-height: 1.6;
  }

  .game-panel {
    padding: 10px;
  }

  .hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .hud-item {
    padding: 10px 12px;
  }

  .touch-controls {
    display: grid;
  }

  .has-touch-device .mobile-touch-layer {
    display: block;
    pointer-events: auto;
  }

  .side-panel {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .card {
    padding: 14px;
    border-radius: 18px;
  }
}

@media (max-width: 520px) {
  .mobile-controls-row {
    gap: 12px;
  }

  .swipe-guide {
    min-height: 120px;
    padding: 14px;
  }

  .attack-btn {
    min-width: 118px;
    min-height: 118px;
  }

  .skill-btn {
    min-width: 118px;
  }
}


.card-description,
.status-text,
.input-label {
  color: var(--muted);
}

.card-description,
.status-text {
  line-height: 1.7;
}

.card-description {
  margin: 0 0 14px;
}

.ranking-controls {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.input-label {
  font-size: 0.9rem;
  font-weight: 700;
}

.text-input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.1);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  font: inherit;
  outline: none;
}

.text-input:focus {
  border-color: rgba(77, 178, 255, 0.7);
  box-shadow: 0 0 0 3px rgba(77, 178, 255, 0.14);
}

.text-input::placeholder {
  color: rgba(255,255,255,0.38);
}

.ranking-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.small-button {
  min-height: 46px;
  padding: 10px 14px;
  font-weight: 700;
}

.small-button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.ranking-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.ranking-item,
.ranking-empty {
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.07);
}

.ranking-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
}

.ranking-highlight {
  border-color: rgba(77, 178, 255, 0.55);
  box-shadow: 0 0 0 2px rgba(77, 178, 255, 0.12) inset;
}

.ranking-rank {
  min-width: 56px;
  padding: 8px 10px;
  border-radius: 999px;
  text-align: center;
  font-weight: 800;
  background: linear-gradient(180deg, rgba(92,192,255,0.22), rgba(30,152,246,0.14));
  color: #dff4ff;
}

.ranking-main {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.ranking-name-row,
.ranking-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ranking-name {
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-score {
  color: #ffd58a;
  font-weight: 800;
  white-space: nowrap;
}

.ranking-meta {
  color: var(--muted);
  font-size: 0.88rem;
}

.ranking-empty {
  color: var(--muted);
  text-align: center;
}

@media (max-width: 520px) {
  .ranking-actions {
    grid-template-columns: 1fr;
  }

  .ranking-item {
    grid-template-columns: 1fr;
  }

  .ranking-rank {
    min-width: 0;
    width: fit-content;
  }

  .ranking-name-row,
  .ranking-meta {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
}


body.has-touch-device .touch-controls {
  display: grid;
}

@media (hover: none) and (pointer: coarse) {
  .touch-controls {
    display: grid;
  }

  .has-touch-device .mobile-touch-layer {
    display: block;
    pointer-events: auto;
  }
}

body.has-touch-device.game-scroll-locked .game-shell,
body.has-touch-device.game-scroll-locked canvas,
body.has-touch-device.game-scroll-locked .touch-controls,
body.has-touch-device.game-scroll-locked .mobile-touch-layer {
  touch-action: none;
}

body.has-touch-device.game-scroll-locked .touch-btn {
  touch-action: none;
}

@media (max-width: 900px) and (hover: none) and (pointer: coarse) {
  .page {
    width: min(100%, calc(100% - 12px));
    margin: 12px auto 28px;
  }

  .game-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-columns: 1fr;
    gap: 12px;
  }
}


.admin-link { text-decoration: none; display: inline-flex; align-items: center; }
