:root {
  --sea: #1a535c;
  --sea-light: #4ecdc4;
  --sand: #ffe66d;
  --coral: #ff6b6b;
  --sky: #a8e6cf;
  --night: #0d2b36;
  --card: #fff8e7;
  --pixel-shadow: 4px 4px 0 #0d2b36;
  --font: 'Press Start 2P', monospace;
}

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

html { font-size: 14px; }

body {
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--night);
  overflow-x: hidden;
  line-height: 1.7;
}

.ocean-bg {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, #87ceeb 0%, var(--sky) 35%, var(--sea-light) 60%, var(--sea) 100%);
}

.ocean-bg::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 80px;
  background: repeating-linear-gradient(
    90deg,
    var(--sand) 0px, var(--sand) 20px,
    #f4d35e 20px, #f4d35e 40px
  );
  image-rendering: pixelated;
}

.game-shell {
  max-width: 520px;
  margin: 0 auto;
  padding: 12px 12px 24px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
}

/* Language switcher */
.lang-switcher {
  position: absolute;
  top: 8px;
  right: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  z-index: 2;
}

.lang-label {
  font-size: 0.7rem;
  line-height: 1;
}

.lang-select {
  font-family: var(--font);
  font-size: 0.42rem;
  padding: 8px 6px;
  border: 3px solid var(--night);
  background: var(--card);
  color: var(--night);
  box-shadow: 2px 2px 0 var(--night);
  cursor: pointer;
  max-width: 130px;
}

.lang-select:focus {
  outline: 2px solid var(--sea-light);
  outline-offset: 2px;
}

/* Header */
.game-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
  margin-top: 28px;
  animation: slideDown 0.5s ease;
}

.tony-avatar {
  width: 128px;
  height: 128px;
  image-rendering: pixelated;
  flex-shrink: 0;
  animation: bob 2s ease-in-out infinite;
  filter: drop-shadow(4px 4px 0 var(--night));
}

.header-text {
  flex: 1;
  min-width: 0;
  background: var(--card);
  border: 3px solid var(--night);
  box-shadow: var(--pixel-shadow);
  padding: 12px 14px;
}

.header-text h1 {
  font-size: 0.58rem;
  color: var(--night);
  line-height: 1.75;
}

.subtitle {
  font-size: 0.46rem;
  color: var(--sea);
  margin-top: 8px;
  line-height: 1.6;
}

/* Day bar */
.day-bar-wrap {
  margin-bottom: 10px;
  animation: fadeIn 0.4s;
}

.day-label {
  display: flex;
  justify-content: space-between;
  font-size: 0.45rem;
  margin-bottom: 4px;
  color: var(--sea);
}

.day-bar {
  height: 14px;
  background: var(--night);
  border: 3px solid var(--night);
  padding: 2px;
}

.day-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--sand), var(--coral));
  transition: width 0.6s steps(8);
}

/* Stats */
.stats-panel {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin-bottom: 12px;
  animation: fadeIn 0.4s;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 5px;
  background: var(--card);
  border: 2px solid var(--night);
  padding: 6px 8px;
  box-shadow: 2px 2px 0 var(--night);
}

.stat-head {
  display: flex;
  align-items: center;
  gap: 5px;
  min-height: 1.6rem;
}

.stat-emoji { font-size: 1.2rem; line-height: 1; flex-shrink: 0; }

.stat-tag {
  font-size: 0.34rem;
  line-height: 1.45;
  color: var(--sea);
  flex: 1;
  word-break: break-word;
}

.stat-bar {
  width: 100%;
  height: 12px;
  flex-shrink: 0;
  background: #ddd;
  border: 1px solid var(--night);
  overflow: hidden;
  position: relative;
}

.stat-fill {
  display: block;
  height: 100%;
  width: 0%;
  min-width: 0;
  background: var(--sea-light);
  transition: width 0.4s ease, background 0.3s;
}

.stat[data-stat="caos"] .stat-fill { background: var(--coral); }
.stat.low .stat-fill { background: var(--coral); }
.stat.high .stat-fill { background: #7bed9f; }

/* Screens */
.game-main { flex: 1; display: flex; flex-direction: column; }

.screen {
  display: none;
  flex: 1;
  animation: fadeIn 0.35s;
}

.screen.active { display: flex; flex-direction: column; }

.pixel-card {
  background: var(--card);
  border: 4px solid var(--night);
  box-shadow: var(--pixel-shadow);
  padding: 20px 16px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
}

/* Start */
.intro-text {
  font-size: 0.55rem;
  line-height: 2;
  max-width: 340px;
}

.deco-bounce {
  font-size: 3rem;
  animation: bounce 0.8s ease infinite alternate;
}

/* Event */
.event-icon {
  font-size: 3rem;
  animation: wiggle 1s ease infinite;
}

.event-text {
  font-size: 0.55rem;
  line-height: 2;
  max-width: 380px;
}

.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 360px;
}

/* Buttons */
.btn-pixel {
  font-family: var(--font);
  font-size: 0.5rem;
  padding: 14px 16px;
  border: 3px solid var(--night);
  background: var(--sea-light);
  color: var(--night);
  cursor: pointer;
  box-shadow: var(--pixel-shadow);
  transition: transform 0.1s, box-shadow 0.1s;
  line-height: 1.6;
  width: 100%;
}

.btn-pixel:hover {
  background: var(--sand);
  transform: translate(-1px, -1px);
  box-shadow: 5px 5px 0 var(--night);
}

.btn-pixel:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--night);
}

.btn-start { background: var(--coral); color: #fff; max-width: 240px; }
.btn-continue { background: var(--sand); max-width: 200px; }
.btn-restart { background: var(--sea-light); max-width: 260px; margin-top: 8px; }

.choice-btn { text-align: left; }

/* Result */
.result-text {
  font-size: 0.55rem;
  line-height: 2;
  max-width: 380px;
  color: var(--sea);
}

/* End */
.end-emoji { font-size: 3.5rem; animation: bounce 1s ease infinite alternate; }
.end-title { font-size: 0.75rem; color: var(--coral); line-height: 1.8; }
.end-subtitle { font-size: 0.55rem; color: var(--sea); line-height: 2; margin-top: 4px; }
.end-text { font-size: 0.5rem; line-height: 2; max-width: 380px; }
.congrats-text { margin-top: 8px; }

.laugh-line {
  font-size: 1rem;
  line-height: 1.4;
  margin: 10px 0;
  letter-spacing: 2px;
}

.laugh-line.big { font-size: 1.1rem; }

.final-stats-title {
  font-size: 0.55rem;
  color: var(--sea);
  margin: 8px 0 12px;
  line-height: 1.8;
}

.funny-stats {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 360px;
  text-align: left;
}

.funny-stat {
  font-size: 0.48rem;
  line-height: 1.8;
  background: #fff;
  border: 2px solid var(--night);
  padding: 8px 10px;
  box-shadow: 2px 2px 0 var(--night);
}

.achievement-block {
  width: 100%;
  max-width: 360px;
  margin-top: 4px;
}

.achievement-intro {
  font-size: 0.5rem;
  color: var(--coral);
  margin-bottom: 10px;
  line-height: 1.8;
}

.achievement-card {
  background: linear-gradient(135deg, var(--sand), #fff8c4);
  border: 3px solid var(--night);
  padding: 14px 12px;
  box-shadow: var(--pixel-shadow);
}

.achievement-card.locked {
  background: #eee;
  opacity: 0.85;
}

.achievement-label {
  font-size: 0.45rem;
  color: var(--sea);
  margin-bottom: 8px;
}

.achievement-name {
  font-size: 0.55rem;
  color: var(--coral);
  line-height: 1.8;
  margin-bottom: 8px;
}

.achievement-rare {
  font-size: 0.42rem;
  line-height: 1.8;
  color: var(--night);
}

.ending-banner {
  width: 100%;
  max-width: 360px;
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 2px dashed var(--sea-light);
}

.ending-story {
  text-align: left;
  margin-top: 8px;
}

.end-card {
  justify-content: flex-start;
  padding-top: 16px;
  overflow-y: auto;
  max-height: 72dvh;
}

/* Footer */
.game-footer {
  text-align: center;
  font-size: 0.4rem;
  color: var(--sea);
  margin-top: 12px;
  display: flex;
  justify-content: center;
  gap: 8px;
  align-items: center;
}

.blink { animation: blink 1.2s step-end infinite; }

/* Animations */
@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-4px); }
}

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

@keyframes wiggle {
  0%, 100% { transform: rotate(-3deg); }
  50% { transform: rotate(3deg); }
}

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

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

@keyframes blink {
  50% { opacity: 0; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.shake { animation: shake 0.3s ease; }

/* Responsive */
@media (max-width: 380px) {
  html { font-size: 12px; }
  .stats-panel { grid-template-columns: repeat(2, 1fr); }
  .tony-avatar { width: 100px; height: 100px; }
  .header-text h1 { font-size: 0.5rem; }
}

@media (min-width: 521px) {
  .game-shell { padding-top: 24px; }
}
