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

body {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: #1a1a2e;
  font-family: 'Courier New', monospace;
  gap: 0;
}

#mainArea {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 0;
  padding: 8px;
}

#gameContainer {
  width: min(70vw, calc(70vh * 800 / 480));
  aspect-ratio: 800 / 480;
  max-height: 70vh;
  box-shadow: 0 0 40px rgba(0,0,0,0.5);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #87CEEB;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

#menu {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75);
  z-index: 110;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: center;
  gap: 48px;
  padding: 24px;
}

#menuContent {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

#scoreboard {
  min-width: 320px;
  max-width: 420px;
  background: rgba(33, 33, 33, 0.9);
  border: 3px solid #424242;
  padding: 16px;
}

#scoreboard h3 {
  color: #fff;
  font-size: 1rem;
  margin-bottom: 12px;
  text-align: center;
}

#scoreboardList {
  list-style: none;
  margin: 0;
  padding: 0;
  font-family: 'Courier New', monospace;
  font-size: 0.95rem;
  color: #ccc;
}

#scoreboardList li {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
  padding: 4px 0;
  border-bottom: 1px solid #333;
}

#scoreboardList li .sb-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#scoreboardList li .sb-score {
  flex-shrink: 0;
  min-width: 3ch;
  text-align: right;
}

#scoreboardList li:last-child {
  border-bottom: none;
}

#scoreboardList li.current {
  color: #FFEB3B;
  font-weight: bold;
  background: rgba(255, 235, 59, 0.15);
  margin: 2px -8px;
  padding: 4px 8px;
}

#scoreboardList li.current .sb-name,
#scoreboardList li.current .sb-score {
  color: inherit;
}

#menuLogo {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 8px;
}

#menuLogo img {
  width: 72px;
  height: 72px;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  border: 3px solid #5D4037;
}

#menu h1 {
  color: #fff;
  font-size: 2.5rem;
  font-weight: bold;
  letter-spacing: 0.1em;
  text-shadow: 2px 2px 0 #333;
}

#menuButtons {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#menu button {
  padding: 14px 48px;
  font-size: 1.1rem;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  cursor: pointer;
  background: #616161;
  color: #fff;
  border: 3px solid #424242;
  border-radius: 0;
  transition: background 0.15s;
}

#menu button:hover {
  background: #757575;
}

#menu button:active {
  background: #424242;
}

#menu button#btnStart {
  background: #228B22;
  border-color: #1B5E20;
}

#menu button#btnStart:hover { background: #2E7D32; }

#menu button#btnContinue {
  background: #FF9800;
  border-color: #E65100;
}

#menu button#btnContinue:hover { background: #FFB74D; }

#menu.hidden { display: none; }

#settings {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75);
  z-index: 112;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
}

#settings.visible { display: flex; }

#settings h2 { color: #fff; font-size: 1.8rem; margin-bottom: 8px; }

#settings .settings-lang {
  display: flex;
  gap: 16px;
  margin-bottom: 4px;
}
#settings .lang-flag {
  width: 64px;
  height: 64px;
  font-size: 1.2rem;
  font-weight: bold;
  font-family: 'Courier New', monospace;
  line-height: 1;
  padding: 0;
  background: #333;
  color: #888;
  border: 3px solid #424242;
  border-radius: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
#settings .lang-flag:hover {
  background: #444;
  color: #aaa;
}
#settings .lang-flag.lang-active {
  background: #616161;
  color: #fff;
  border-color: #FF9800;
}
#settings .lang-flag.lang-active:hover {
  background: #757575;
}

#settings .settings-form { display: flex; flex-direction: column; gap: 12px; align-items: center; }

#settings label { color: #fff; font-size: 1rem; }

#settings input {
  padding: 10px 16px;
  font-size: 1rem;
  font-family: 'Courier New', monospace;
  width: 220px;
  border: 3px solid #424242;
  background: #333;
  color: #fff;
}

#settings .settings-buttons { display: flex; gap: 12px; }

#settings button {
  padding: 12px 32px;
  font-size: 1rem;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  cursor: pointer;
  background: #616161;
  color: #fff;
  border: 3px solid #424242;
  border-radius: 0;
}

#settings button:hover { background: #757575; }

#settings #btnSaveName { background: #228B22; border-color: #1B5E20; }

#settings #btnSaveName:hover { background: #2E7D32; }

#settings .settings-message { color: #4CAF50; font-size: 0.9rem; min-height: 1.2em; }

#gameOver {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.75);
  z-index: 111;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 16px;
}

#gameOver.visible { display: flex; }

#gameOver h2 {
  color: #f44336;
  font-size: 2.5rem;
  font-weight: bold;
  letter-spacing: 0.1em;
  text-shadow: 2px 2px 0 #333;
  margin-bottom: 8px;
}

#gameOver .score { color: #fff; font-size: 1.2rem; margin-bottom: 8px; }

#gameOver .gameOverNoName {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

#gameOver .gameOverNoNameMsg {
  color: #FFEB3B;
  font-size: 1rem;
  text-align: center;
  max-width: 320px;
}

#gameOver .gameOverNoName input {
  padding: 12px 20px;
  font-size: 1.1rem;
  font-family: 'Courier New', monospace;
  width: 240px;
  border: 3px solid #424242;
  background: #333;
  color: #fff;
}

#gameOver .gameOverNoName #btnGameOverSave {
  background: #228B22;
  border-color: #1B5E20;
}

#gameOver .gameOverNoName #btnGameOverSave:hover { background: #2E7D32; }

#gameOver .gameOverSaveMsg { font-size: 0.9rem; min-height: 1.2em; }

#gameOverButtons { display: flex; flex-direction: column; gap: 8px; }

#gameOver button {
  padding: 14px 48px;
  font-size: 1.1rem;
  font-family: 'Courier New', monospace;
  font-weight: bold;
  cursor: pointer;
  background: #616161;
  color: #fff;
  border: 3px solid #424242;
  border-radius: 0;
}

#gameOver button:hover { background: #757575; }

#gameOver #btnGameOverZnovu { background: #228B22; border-color: #1B5E20; }

#gameOver #btnGameOverZnovu:hover { background: #2E7D32; }

#btnMenu {
  position: fixed;
  top: 12px;
  left: 12px;
  width: 44px;
  height: 44px;
  background: #fff;
  border: 3px solid #333;
  border-radius: 0;
  cursor: pointer;
  display: none;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  z-index: 100;
}

#btnMenu span {
  display: block;
  width: 22px;
  height: 3px;
  background: #333;
}

#btnMenu:active { background: #eee; }

#pageFooter {
  flex: 0 0 auto;
  margin-top: auto;
  padding: 12px 20px;
  color: #BABABA;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

#pageFooter a {
  color: #BABABA;
  text-decoration: none;
}

#pageFooter a:hover {
  color: #ddd;
}

#pageFooter .heart-icon {
  display: inline-block;
  width: 14px;
  height: 14px;
  vertical-align: middle;
}

#touchControlsLeft, #touchControlsRight {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
  touch-action: none;
  user-select: none;
  z-index: 50;
  pointer-events: none;
}
#touchControlsLeft { left: 12px; }
#touchControlsRight { right: 12px; }
#touchControlsLeft *, #touchControlsRight * { pointer-events: auto; }

#touchControlsLeft .btnJump {
  width: 80px;
  height: 80px;
  background: #757575;
  border: 4px solid #424242;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0;
  border-radius: 50%;
}

#touchControlsLeft .btnJump:active {
  background: #9e9e9e;
}

#touchControlsLeft .btnJump {
  position: relative;
}

#touchControlsLeft .arrow {
  width: 0;
  height: 0;
  border-style: solid;
  flex-shrink: 0;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

#touchControlsLeft .arrow-up {
  border-width: 0 14px 22px 14px;
  border-color: transparent transparent #333 transparent;
}

#touchControlsLeft .btnAttack {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: #f44336;
  border: 4px solid #c62828;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

#touchControlsLeft .btnAttack:active {
  background: #d32f2f;
}

#touchControlsLeft .btnAttack::after {
  content: '';
  width: 24px;
  height: 24px;
  background: #fff;
  border-radius: 50%;
}

#touchControlsRight {
  flex-direction: row;
}

#touchControlsRight button {
  width: 80px;
  height: 80px;
  background: #757575;
  border: 4px solid #424242;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  position: relative;
  font-size: 0;
}

#touchControlsRight button:active {
  background: #9e9e9e;
}

#touchControlsRight .arrow {
  width: 0;
  height: 0;
  border-style: solid;
  flex-shrink: 0;
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

#touchControlsRight .arrow-left { border-width: 14px 22px 14px 0; border-color: transparent #333 transparent transparent; }

#touchControlsRight .arrow-right { border-width: 14px 0 14px 22px; border-color: transparent transparent transparent #333; }
