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

:root {
  --bg-dark: #1a1a2e;
  --bg-mid: #16213e;
  --accent: #e94560;
  --accent-green: #4ecca3;
  --text: #eee;
  --text-dim: #888;
}

body {
  font-family: 'Segoe UI', sans-serif;
  background: var(--bg-dark);
  color: var(--text);
  overflow: hidden;
  height: 100vh;
}

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

.screen {
  display: none;
  position: absolute;
  inset: 0;
  padding: 20px;
}

.screen.active { display: flex; flex-direction: column; align-items: center; justify-content: center; }

/* Title */
#screen-title h1 {
  font-size: 3rem;
  color: var(--accent);
  margin-bottom: 40px;
  text-shadow: 0 0 20px rgba(233, 69, 96, 0.5);
}

.menu { display: flex; flex-direction: column; gap: 16px; }

button {
  padding: 12px 32px;
  font-size: 1.1rem;
  border: 2px solid var(--accent);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.2s;
}

button:hover { background: var(--accent); color: white; }

/* HUD */
#hud {
  display: flex;
  gap: 20px;
  font-size: 0.9rem;
  color: var(--text-dim);
}

/* Lobby */
#screen-lobby { justify-content: flex-start; padding-top: 40px; }
.lobby-header { width: 100%; max-width: 800px; display: flex; justify-content: space-between; align-items: center; margin-bottom: 30px; }

#waiting-room {
  display: flex;
  gap: 20px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 800px;
}

.patient-card {
  width: 200px;
  padding: 20px;
  background: var(--bg-mid);
  border: 1px solid #333;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.2s;
  text-align: center;
}

.patient-card:hover { border-color: var(--accent); }
.patient-card .name { font-size: 1.1rem; margin-bottom: 8px; }
.patient-card .complaint { color: var(--text-dim); font-size: 0.85rem; }

/* Diagnosis */
.diagnosis-layout {
  display: grid;
  grid-template-columns: 200px 300px 200px;
  grid-template-rows: auto 1fr auto;
  gap: 20px;
  max-width: 900px;
  width: 100%;
  height: 100%;
  padding: 20px;
}

#patient-info { grid-column: 1; grid-row: 1 / 3; }
#patient-body-container { grid-column: 2; grid-row: 1 / 3; display: flex; justify-content: center; }
#patient-body { max-height: 400px; }
#exam-tools { grid-column: 3; grid-row: 1; display: flex; flex-direction: column; gap: 8px; }
.tool-btn { font-size: 0.85rem; padding: 8px 12px; }
.tool-btn.active { background: var(--accent); color: white; }
#exam-output { grid-column: 1 / 4; grid-row: 3; min-height: 80px; background: var(--bg-mid); padding: 15px; border-radius: 4px; }
#diagnosis-decision { grid-column: 1 / 4; display: flex; gap: 12px; justify-content: center; }

/* Surgery */
.surgery-layout {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: 60px 1fr 100px;
  width: 100%;
  height: 100%;
  max-width: 800px;
}

#surgery-hud { display: flex; align-items: center; justify-content: space-between; }

#blood-bar {
  width: 200px;
  height: 20px;
  background: #333;
  border-radius: 10px;
  overflow: hidden;
}

#blood-fill {
  width: 100%;
  height: 100%;
  background: var(--accent);
  transition: width 0.3s;
}

#surgery-area { display: flex; justify-content: center; align-items: center; }
#surgery-body { max-height: 100%; max-width: 100%; }

#instrument-tray {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
}

.instrument-btn {
  padding: 10px 16px;
  font-size: 0.85rem;
  border: 1px solid #555;
  background: var(--bg-mid);
  color: var(--text);
  cursor: pointer;
  border-radius: 4px;
}

.instrument-btn.active { border-color: var(--accent-green); background: rgba(78, 204, 163, 0.2); }

#surgery-feedback {
  position: fixed;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  padding: 8px 16px;
  background: rgba(0,0,0,0.8);
  border-radius: 4px;
  display: none;
}

/* Result */
#result-content { text-align: center; max-width: 500px; }
#result-title { font-size: 2rem; margin-bottom: 20px; }
#result-details { margin-bottom: 20px; line-height: 1.6; }
#result-stats { margin-bottom: 30px; color: var(--text-dim); }

/* Gameover */
#screen-gameover { text-align: center; }
#screen-gameover h2 { font-size: 2.5rem; color: var(--accent); margin-bottom: 20px; }

/* SVG styles */
.body-zone { cursor: pointer; fill: #deb887; stroke: #333; stroke-width: 1; transition: fill 0.2s; }
.body-zone:hover { fill: #eeca95; }
.body-zone.highlighted { fill: #ffaa44; }

.svg-layer { transition: opacity 0.5s, transform 0.5s; }
.svg-layer.hidden { opacity: 0; pointer-events: none; }
.svg-layer.cut-open { transform: scaleY(0.3); transform-origin: center top; }

.surgery-target { cursor: pointer; }
.surgery-target:hover { filter: brightness(1.3); }
.surgery-target.done { opacity: 0.3; pointer-events: none; }

.blood-splatter {
  fill: #cc0000;
  opacity: 0;
  transition: opacity 0.3s;
}
.blood-splatter.visible { opacity: 0.7; }

.suture-point {
  fill: transparent;
  stroke: #666;
  stroke-width: 1;
  cursor: pointer;
  r: 6;
}
.suture-point:hover { stroke: var(--accent-green); stroke-width: 2; }
.suture-point.sutured { fill: #333; stroke: #333; }

/* Responsive */
@media (max-width: 768px) {
  .diagnosis-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto auto auto;
  }
  #screen-title h1 { font-size: 2rem; }
}

.patient-card {
  transition: transform 0.2s, border-color 0.2s;
}
.patient-card:hover {
  transform: translateY(-4px);
  border-color: var(--accent);
}

#screen-title h1 {
  animation: titlePulse 3s ease-in-out infinite;
}

@keyframes titlePulse {
  0%, 100% { text-shadow: 0 0 20px rgba(233, 69, 96, 0.5); }
  50% { text-shadow: 0 0 40px rgba(233, 69, 96, 0.8), 0 0 60px rgba(233, 69, 96, 0.3); }
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

@keyframes fadeInOut {
  0% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
  15% { opacity: 1; transform: translateX(-50%) translateY(0); }
  85% { opacity: 1; transform: translateX(-50%) translateY(0); }
  100% { opacity: 0; transform: translateX(-50%) translateY(-10px); }
}
