@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&family=Noto+Sans+JP:wght@300;400;700&display=swap');

:root {
  --navy: #0d1421;
  --navy-light: #16213e;
  --cyan: #00e5ff;
  --emerald: #00c9a7;
  --text: #c8d6e5;
  --text-dim: #6b7b8d;
  --panel-bg: rgba(13, 20, 33, 0.85);
  --border: rgba(0, 229, 255, 0.3);
  --font-mono: 'Share Tech Mono', monospace;
  --font-main: 'Noto Sans JP', sans-serif;
}

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

body {
  background: var(--navy);
  color: var(--text);
  font-family: var(--font-main);
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#game-container {
  width: 100%;
  height: 100%;
  position: relative;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Loading */
#loading-screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--navy);
  z-index: 1000;
  transition: opacity 0.5s;
}

#loading-screen.hidden {
  opacity: 0;
  pointer-events: none;
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--navy-light);
  border-top-color: var(--cyan);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.loading-text {
  font-family: var(--font-mono);
  color: var(--cyan);
  margin-top: 16px;
  font-size: 14px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* HUD */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 10;
}

#hud > * {
  pointer-events: auto;
}

.hud-task {
  position: absolute;
  top: 16px;
  left: 16px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  padding: 8px 14px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--cyan);
  max-width: 300px;
  line-height: 1.6;
}

.hud-task::before {
  content: '⌐';
  position: absolute;
  top: -2px;
  left: -2px;
  color: var(--cyan);
  font-size: 18px;
}

.hud-task::after {
  content: '¬';
  position: absolute;
  bottom: -2px;
  right: -2px;
  color: var(--cyan);
  font-size: 18px;
}

.hud-chapter {
  position: absolute;
  top: 16px;
  right: 16px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  padding: 8px 14px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
  text-align: right;
}

.hud-menu-btn {
  position: absolute;
  top: 50px;
  right: 16px;
  background: var(--panel-bg);
  border: 1px solid var(--border);
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 6px 12px;
  cursor: pointer;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.hud-menu-btn:hover {
  background: rgba(0, 229, 255, 0.1);
}

#reticle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border: 1px solid rgba(0, 229, 255, 0.5);
  border-radius: 50%;
  pointer-events: none;
}

#interact-label {
  position: absolute;
  top: calc(50% + 30px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel-bg);
  border: 1px solid var(--border);
  padding: 4px 12px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--cyan);
  display: none;
  pointer-events: none;
  white-space: nowrap;
}

/* Virtual Stick */
#stick-zone {
  position: absolute;
  bottom: 30px;
  left: 30px;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(0, 229, 255, 0.1);
  border: 1px solid var(--border);
  opacity: 0.5;
  display: none;
  touch-action: none;
}

#stick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 229, 255, 0.3);
  border: 1px solid var(--cyan);
}

@media (pointer: coarse) {
  #stick-zone { display: block; }
  #reticle { display: none; }
}

/* Screen Overlay */
#screen-container {
  position: fixed;
  inset: 0;
  z-index: 50;
  pointer-events: none;
}

.screen-overlay {
  position: absolute;
  inset: 0;
  background: var(--panel-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  opacity: 0;
  transform: scale(0.95);
  transition: opacity 0.3s, transform 0.3s;
}

.screen-overlay.screen-visible {
  opacity: 1;
  transform: scale(1);
}

.screen-close-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  background: none;
  border: 1px solid var(--border);
  color: var(--cyan);
  font-size: 20px;
  cursor: pointer;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
}

.screen-close-btn:hover {
  background: rgba(0, 229, 255, 0.1);
}

/* Title Screen */
#title-screen {
  position: fixed;
  inset: 0;
  background: var(--navy);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.title-anim {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 40px;
}

.title-icons-row {
  display: flex;
  gap: 40px;
  align-items: center;
}

.title-icon-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  opacity: 0;
}

.title-icon-appear {
  animation: iconAppear 0.6s ease forwards;
}

.title-icon {
  font-size: 36px;
  filter: grayscale(0.3);
}

.title-icon-label {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-dim);
}

.title-icon-item:last-child .title-icon {
  filter: none;
}

.title-icon-item:last-child .title-icon-label {
  color: var(--cyan);
}

@keyframes iconAppear {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.title-logo {
  font-family: var(--font-mono);
  font-size: clamp(28px, 5vw, 48px);
  color: var(--cyan);
  text-shadow: 0 0 30px rgba(0, 229, 255, 0.5);
  opacity: 0;
  letter-spacing: 4px;
}

.title-logo-appear {
  animation: logoAppear 1s ease forwards;
}

@keyframes logoAppear {
  from { opacity: 0; transform: scale(0.9); }
  to { opacity: 1; transform: scale(1); }
}

.title-subtitle {
  font-family: var(--font-mono);
  font-size: clamp(12px, 2vw, 16px);
  color: var(--text-dim);
  opacity: 0;
  letter-spacing: 2px;
}

.title-menu {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-top: 40px;
  animation: fadeIn 0.5s ease;
}

.title-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 16px;
  padding: 12px 48px;
  cursor: pointer;
  min-width: 200px;
  min-height: 44px;
  transition: all 0.2s;
}

.title-btn:hover {
  background: rgba(0, 229, 255, 0.1);
  border-color: var(--cyan);
  color: var(--cyan);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.name-input-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin-top: 40px;
  animation: fadeIn 0.3s ease;
}

.name-input-title {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--text-dim);
}

.name-input-field {
  background: var(--navy-light);
  border: 1px solid var(--border);
  color: var(--cyan);
  font-family: var(--font-mono);
  font-size: 20px;
  padding: 10px 20px;
  text-align: center;
  outline: none;
  width: 240px;
}

.name-input-field:focus {
  border-color: var(--cyan);
  box-shadow: 0 0 10px rgba(0, 229, 255, 0.2);
}

/* Toast */
#toast-container {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: var(--panel-bg);
  border: 1px solid var(--border);
  padding: 8px 20px;
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--cyan);
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
  white-space: nowrap;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes toastOut {
  from { opacity: 1; }
  to { opacity: 0; }
}
