/* Hearthbound user interface styles. */
@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=Space+Grotesk:wght@400;600;700&display=swap');

:root {
  --ink: #182029;
  --paper: #f7efd8;
  --orange: #f16c3f;
  --mint: #a9e878;
  --line: #29323c;
  --muted: #66717d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: #222b35 radial-gradient(#3b4652 1px, transparent 1px);
  background-size: 20px 20px;
  color: var(--ink);
  font-family: 'Space Grotesk', sans-serif;
}

.shell {
  max-width: 1180px;
  margin: auto;
  padding: 30px 20px;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  color: var(--paper);
}

.header-actions { display: flex; align-items: center; gap: 12px; }
#adminLogin { display: grid; gap: 12px; }
#adminRoomList { display: grid; gap: 8px; margin: 18px 0; }
.admin-room-entry { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px; border: 2px solid var(--line); background: #fffdf5; }

.brand,
h1,
.eyebrow {
  font-family: 'Press Start 2P', monospace;
}

.brand {
  font-size: 18px;
  line-height: 1.5;
}

.brand span {
  display: block;
  margin-top: 5px;
  color: var(--mint);
  font-size: 10px;
}

.language {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
}

.eyebrow {
  color: var(--orange);
  font-size: 10px;
  line-height: 1.5;
}

h1 {
  margin: 14px 0;
  font-size: 26px;
  line-height: 1.5;
}

.muted {
  color: var(--muted);
}

select,
input,
button {
  font: inherit;
}

select,
input {
  padding: 11px;
  border: 2px solid var(--line);
  border-radius: 4px;
  background: #fffdf5;
}

button {
  padding: 11px 16px;
  border: 2px solid var(--ink);
  border-radius: 3px;
  font-weight: 700;
  cursor: pointer;
}

.primary {
  background: var(--orange);
  box-shadow: 3px 3px 0 var(--ink);
}

.secondary,
.leave {
  background: #fffdf5;
}

.leave {
  color: #9e3425;
}

.small {
  display: block;
  margin: 12px 0 2px;
  padding: 7px 9px;
  background: var(--mint);
  font-size: 12px;
}

.browser-button {
  width: 100%;
  margin-top: 12px;
}

#roomBrowserScreen h2 {
  margin-top: 28px;
  font-size: 16px;
}

.room-browser-entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid #d5ccb7;
}

/* Character setup screen. */
.panel {
  max-width: 760px;
  margin: 9vh auto;
  padding: 38px;
  border: 4px solid var(--ink);
  background: var(--paper);
  box-shadow: 8px 8px 0 #101419;
}

.character-panel > label,
.join-box label {
  display: grid;
  gap: 7px;
  font-weight: 700;
}

fieldset {
  margin: 27px 0;
  padding: 0;
  border: 0;
}

legend {
  margin-bottom: 10px;
  font-weight: 700;
}

.types {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.type-card {
  position: relative;
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 2px solid #a0a8a5;
  background: #fffdf5;
  text-align: center;
  cursor: pointer;
}

.type-card.selected {
  border-color: var(--ink);
  box-shadow: 4px 4px 0 var(--orange);
}

.type-card input {
  position: absolute;
  opacity: 0;
}

.type-card small {
  color: var(--muted);
  font-size: 12px;
}

.class-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
  padding-top: 6px;
  border-top: 1px solid #d5ccb7;
  color: var(--ink);
  font-size: 10px;
}

.class-stats span {
  display: grid;
  gap: 2px;
}

.class-stats b {
  color: var(--orange);
  font-size: 11px;
}

.avatar {
  width: 40px;
  height: 33px;
  margin: auto;
  background-color: transparent;
  background-repeat: no-repeat;
  background-size: 320px 264px;
  image-rendering: pixelated;
}

.avatar.fast {
  background-image: url('../assets/characters/fast.png');
}

.avatar.strong {
  background-image: url('../assets/characters/strong.png');
}

.avatar.balanced {
  background-image: url('../assets/characters/balanced.png');
}

.actions,
.join-box {
  display: flex;
  gap: 12px;
}

.join-box {
  align-items: end;
  margin-top: 18px;
}

.join-box label {
  flex: 1;
}

.error {
  min-height: 20px;
  color: #bd2f2f;
  font-weight: 700;
}

/* Game arena and sidebar. */
.game-layout {
  display: grid;
  grid-template-columns: 1fr 286px;
  gap: 16px;
}

.world-wrap {
  position: relative;
  border: 4px solid var(--ink);
  background: #87c667;
  box-shadow: 7px 7px 0 #101419;
}

.world-wrap canvas {
  display: block;
  width: 100%;
  height: auto;
  image-rendering: pixelated;
}

.hint {
  position: absolute;
  bottom: 12px;
  left: 12px;
  padding: 8px;
  color: #fff;
  background: #182029dc;
  font-size: 12px;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.battle-map-picker {
  display: grid;
  gap: 6px;
  margin: 10px 0;
  font-size: 13px;
  font-weight: 700;
}

.battle-map-picker select {
  width: 100%;
}

.sidebar section {
  padding: 14px;
  border: 3px solid var(--ink);
  background: var(--paper);
}

.room-card strong {
  font: 17px 'Press Start 2P', monospace;
  letter-spacing: 2px;
}

.section-title {
  display: flex;
  justify-content: space-between;
}

.players-card ul {
  margin: 10px 0 0;
  padding: 0;
  list-style: none;
}

.players-card li {
  padding: 6px 0;
  border-bottom: 1px solid #d5ccb7;
  font-size: 14px;
}

.dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-right: 7px;
  background: var(--c);
}

.chat-card {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-height: 240px;
}

.chat-card #messages {
  flex: 1;
  overflow: auto;
  margin: 10px -4px;
  padding: 0 4px;
  font-size: 13px;
}

.message {
  margin: 0 0 7px;
  word-break: break-word;
}

.system {
  color: var(--muted);
  font-style: italic;
}

.chat-card form {
  display: flex;
}

.chat-card input {
  width: 100%;
  min-width: 0;
  padding: 8px;
}

.chat-card button {
  background: var(--orange);
}

/* Winner screen. */
.winner-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: #fff6dc;
  background: #182029e8;
  text-align: center;
}

.winner-overlay[hidden] {
  display: none !important;
}

.winner-overlay strong {
  position: relative;
  z-index: 1;
  font: 18px 'Press Start 2P', monospace;
  text-shadow: 3px 3px var(--ink);
}

.winner-overlay span {
  position: relative;
  z-index: 1;
  color: var(--mint);
  font: 28px 'Press Start 2P', monospace;
  text-shadow: 4px 4px var(--ink);
}

.winner-avatar-slot {
  display: grid;
  padding: 20px;
  width: 150px;
  height: 150px;
  place-items: center;
}

.winner-avatar {
  margin: 0 !important;
  transform: scale(3);
}

.winner-actions {
  display: flex;
  gap: 12px;
}

#postMatchStatus {
  margin: 0;
  color: var(--paper);
}

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

  .sidebar {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .chat-card {
    min-height: 200px;
  }

  .types {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .shell {
    padding: 16px 10px;
  }

  .panel {
    margin: 20px auto;
    padding: 24px 18px;
  }

  .sidebar {
    display: flex;
  }

  .join-box {
    display: grid;
  }

  .brand {
    font-size: 13px;
  }
}
