
#gold-counter-box {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background-color: rgba(245, 245, 220, 0.6); /* translucent box */
  color: #000;
  padding: 8px;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  border-radius: 5px;
  z-index: 3;
  text-align: left;
}

#gold-counter-box span {
  font-weight: bold;
}
:root {
  --font-title: 'Papyrus', 'Herculanum', 'IM Fell English', serif;
  --font-body: 'Herculanum', 'IM Fell English', serif;
  --text: #2b2b2b;
}

body {
  margin: 0;
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 600px at 50% 40%, rgba(0,0,0,0.06) 0%, rgba(0,0,0,0.12) 55%, rgba(0,0,0,0.18) 100%),
    linear-gradient(180deg, #efe0c2 0%, #e6d3af 60%, #dbc79e 100%);
  display: block;
  color: var(--text);
}

/* Canvas wrapper to constrain size and center the canvas */
/* App layout */
#app h1 {
  text-align: center;
  margin: 16px 0 8px;
  font-family: var(--font-title);
  font-size: 20px;
  color: #2b2b2b;
}

.game-layout {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: auto 320px; /* canvas gets flexible space, sidebar fixed right */
  grid-auto-rows: auto; /* rows sized to content */
  gap: 32px; /* more space between sidebar and canvas */
  align-items: start;
  justify-content: center;
  padding: 8px 24px 24px; /* add lateral breathing room */
}

.game-layout #gameCanvas { grid-column: 1; grid-row: 1; justify-self: end; align-self: start; }
#sidebar { grid-column: 2; grid-row: 1; align-self: start; }

/* Score bar sits below canvas in first column */
.scorebar {  
  grid-column: 1; 
  grid-row: 2; 
  justify-self: end; 
  align-self: start; 
  margin-top: 8px; 
  background: linear-gradient(180deg, #3a2a1a, #2b2116);
  color: #f6e9cc;
  border-radius: 8px;
  border: 1px solid rgba(255,210,100,0.35);
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.scorebar .coin { margin-right: 6px; }
.scorebar .unit { opacity: 0.8; margin-left: 4px; }
.scorebar .sep { opacity: 0.5; margin: 0 8px; }
.scorebar .score-left, .scorebar .score-right { font-family: var(--font-body); font-size: 13px; }

canvas {
  display: block;
  background-color: #e6d3af;
  border: 1px solid rgba(68, 47, 25, 0.35);
  image-rendering: auto;
  /* Let JS control size; avoid implicit shrinking */
  width: auto;
  height: auto;
}

#menu-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: absolute;
  width: 100%;
  height: 100%;
  /* Parchment-like background with soft vignette and subtle grain */
  background:
    radial-gradient(1200px 600px at 50% 40%, rgba(0,0,0,0.12) 0%, rgba(0,0,0,0.22) 55%, rgba(0,0,0,0.35) 100%),
    linear-gradient(180deg, #efe0c2 0%, #e6d3af 60%, #dbc79e 100%);
  color: #3a2a1a;
  text-align: center;
  z-index: 10;
}

#menu-screen::before {
  /* central parchment card */
  content: '';
  position: absolute;
  left: 5%;
  right: 5%;
  top: 12%;
  bottom: 12%;
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.03) 0, rgba(255,255,255,0.03) 2px, rgba(0,0,0,0.02) 3px, rgba(0,0,0,0.02) 4px),
    linear-gradient(180deg, #f6e9cc, #eadbb6);
  border: 2px solid rgba(68, 47, 25, 0.35);
  box-shadow: 0 8px 40px rgba(0,0,0,0.35), inset 0 0 30px rgba(0,0,0,0.08);
  border-radius: 12px;
  z-index: -1;
}

#menu-screen h2,
#menu-screen p {
  color: #3a2a1a;
  text-shadow: none;
}

#start-button {
  margin-top: 20px;
  padding: 12px 24px;
  background-color: #8b5a2b;
  border: none;
  font-size: 18px;
  cursor: pointer;
  border-radius: 6px;
  color: #f6e9cc;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(33, 22, 11, 0.4);
}

#start-button:hover {
  background-color: #744a23;
}

/* Sidebar */
#sidebar {
  width: 320px;
}

.sidebar-panel {
  background:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.06) 0, rgba(255,255,255,0.06) 2px, rgba(0,0,0,0.03) 3px, rgba(0,0,0,0.03) 4px),
    linear-gradient(180deg, #f6e9cc, #eadbb6);
  color: #3a2a1a;
  padding: 12px 12px 10px;
  border-radius: 8px;
  box-shadow: 0 8px 20px rgba(0,0,0,0.15);
  border: 1px solid rgba(68, 47, 25, 0.35);
  margin-bottom: 12px;
}
.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.panel-toggle {
  background: linear-gradient(180deg, #6c583e, #4e3f2c);
  color: #f6e9cc;
  border: 1px solid rgba(33,22,11,0.4);
  border-radius: 4px;
  font-family: var(--font-body);
  font-size: 12px;
  padding: 2px 8px;
  cursor: pointer;
}
.sidebar-panel.collapsed .panel-body { display: none; }

.sidebar-panel h3 {
  margin: 0 0 8px;
  font-size: 18px;
  font-family: var(--font-title);
  letter-spacing: 0.5px;
}

.controls-list {
  list-style: none;
  padding: 0;
  margin: 0;
  font-family: var(--font-body);
  font-size: 12px;
}
.controls-list li {
  margin: 6px 0;
}
.controls-list code {
  background: rgba(58,42,26,0.15);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: var(--font-body);
}

.event-log {
  list-style: none;
  padding: 0;
  margin: 0;
  /* Default: tight, ~3 rows visible */
  max-height: 60px;
  overflow: auto;
  transition: max-height 0.2s ease;
}
.event-log:hover,
.event-log.expanded {
  /* Expanded view on hover or when toggled via hotkey */
  max-height: 210px;
}
.event-log li {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 12px;
  color: #3a2a1a;
  padding: 4px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.event-log .log-icon {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  flex: 0 0 10px;
  margin-top: 2px;
}

.legend-list {
  list-style: none;
  padding: 0;
  margin: 0;
}
.legend-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text);
  padding: 4px 0;
}
.swatch {
  width: 16px;
  height: 6px;
  background: #ffd166;
  border-radius: 3px;
  display: inline-block;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25);
}
.swatch.glow {
  position: relative;
  background: #ffd166;
}
.swatch.glow::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 100%;
  height: 100%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 8px 2px rgba(255, 210, 100, 0.9);
  border-radius: 3px;
}

/* Fixed key bindings help box */
#key-help {
  position: fixed;
  left: 16px;
  bottom: 16px;
  max-width: 360px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-family: monospace;
  font-size: 12px;
  line-height: 1.4;
  padding: 8px 10px;
  border-radius: 6px;
  z-index: 5;
}
