:root {
  --bg: #0e141b;
  --panel: #111b25;
  --accent: #48c78e;
  --text: #e6f1ff;
  --muted: #9bb0c7;
  --border: #1f2a36;
  --danger: #ff6b6b;
  --warn: #ffbf69;
}

* {
  box-sizing: border-box;
}

#rotate-guidance {
  display: none; /* Hidden by default in landscape */
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: black;
  color: white;
  text-align: center;
  padding-top: 50px;
  z-index: 800;
}

@media screen and (orientation: portrait) {
  #rotate-guidance {
    display: block; /* Shown only in portrait mode */
  }
}

html, body {
  height: 100%;
  width: 100%;
  font-size: 8pt;;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(135deg, #0b1016, #0f1a23);
  color: var(--text);
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 8px;
}

.bar {
  min-width: 700px;
  max-width: 800px;
  width: 700px;  
  /* position: fixed; */
  top: 0;
/*   left: 0; 
  right: 0; */
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

h1 {
  margin: 0;
  letter-spacing: 0.5px;
}

.sub {
  margin: 4px 0 0;
  color: var(--muted);
}

.meta {
  display: flex;
  min-width: 400px;
  max-width: 450px;
  width: 450px;  
  justify-content: flex-end;
  gap: 8px;;
  text-align: right;
  font-weight: 600;
}

/* #main-container {
  margin-top: 50px;
  position:fixed;
} 
*/
.layout {
  display: grid;
  grid-template-columns: 1fr;
  margin-top: 4px;
}
#top-buttons {
  display: grid;  
  justify-content: right;
  align-items: right;
  align-content: right;
  direction: row;
  gap: 5px;
}
.top {
  display: flex;
  min-width: 600px;
  max-width: 650px;
  width: 650px;
  gap: 12px;
}
/* .top {  
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 12px;
} */
.panel.map-wrap {
  min-width: 250px;
  max-width: 250px;
  width: 250px;  

}
.right {
  min-width: 300px;
  max-width: 300px;
  width: 300px;  
  display: flex;
  flex-direction: column;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2px 12px 2px 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
}

.panel h2 {
  margin-top: 0;
  margin-bottom: 8px;
  letter-spacing: 0.5px;
}

.stats {
  min-width: 300px;
  max-width: 300px;
  width: 300px;
}
.stats p {
  margin: 4px 0;
}

td.move {
  text-transform: capitalize;
  padding: 0px;
  border-radius: 4px;
  border: 0;
  align-items: center;
  align-content: center;
  justify-content: center;
  justify-items: center;
  justify-self: center;
  text-align: center;
}

.status-grid {
  display: grid;
  /* Creates 4 rows, with content flowing into the next column */
  grid-template-rows: repeat(4, min-content);
  /* Flows items into columns first, then wraps to new columns */
  grid-auto-flow: column;
  /* Sets the width of each column to be equal */
  grid-template-columns: repeat(2, 1fr); 
  /* Optional: Adds space between the items */
  gap: 3px; 
}

.status-grid > div > span.label, span.label {
  display: inline-block;
  font-weight: bold;
  margin-right: 4px;
  min-width: 100px;
}
.status-grid > div > span.value, span.value {
  display: inline-block;
  font-weight: normal;
  min-width: 30px;
}

.tools-grid, .inventory-grid{ 
  display: grid;
  grid-auto-flow: column;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
  margin-top: 8px;
}

.tools-grid {
  grid-template-rows: repeat(auto-fill, min-content);
}
.inventory-panel {
  display: none;
}
.inventory-grid {
  grid-template-rows: repeat(3, min-content);
}

.panel.actions {
  min-width: 700px;
  max-width: 800px;
  width: 700px;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#actions {
  display: flex;
  
  gap: 8px;
}

#action-buttons{
  flex-wrap: wrap;
  display: grid;
  /* Creates 2 rows, with content flowing into the next column */
  grid-template-rows: repeat(2, min-content);
  /* Flows items into columns first, then wraps to new columns */
  grid-auto-flow: row;
  /* Sets the width of each column to be equal */
  grid-template-columns: repeat(7, 36px);
  /* Optional: Adds space between the items */
  gap: 2px;
}
button.action {
  background: #1d3042;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 100%;
  min-width: 35px;
  max-width: 50px;
  width: 35px;
  min-height: 36px;
  max-height: 36px;
  height: 36px;
  padding: 3px 0px;
  cursor: pointer;
  font-size: 11px;
  line-height: 1.2;
  transition: transform 0.05s ease, border-color 0.2s ease, box-shadow 0.2s ease;
}

button.action:hover:not(:disabled) {
  border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(72, 199, 142, 0.25);
}

button.action:active:not(:disabled) {
  transform: translateY(1px);
}

button.action:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.move-controls {
  display: block;
}

.move.action {
  min-width: 40px;
  max-width: 40px;
  width: 40px;  
  text-align: center;
  padding: 2px;;
}
.make {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.make-controls {
  display: flex;
/*   grid-template-columns: 1fr auto; */
  gap: 2px;
  align-items: center;
}

.recipe-summary {
  color: var(--accent);
  font-size: 12px;
  font-weight: 500;
  min-height: 20px;
}

.make select {
  font-size: 12px;
  background: #152433;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
}

.recipe-hint {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 11px;
}
.eat-control {
  display: grid;
  /* Defines two columns: 1 part for the first, 1 part for the second */
  grid-template-columns: 1fr 1fr;
  /* Optional: adds space between the columns */
  column-gap: 2px;
  flex-direction: row;
  /* Aligns items vertically centered */
  gap: 2px;
  flex-wrap: wrap;
  align-items: center;
}
.eat-control select, #eat-select {
  background: #152433;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  height: 28px;
}
.feedback #latest {
  min-height: 40px;
  color: var(--warn);
}

.panel.log {
  display:none;
}
.log {
  height: 200px;
  overflow-y: auto;
  font-size: 11px;
  display: flex;
  flex-direction: column-reverse;
  gap: 4px;
}

.map-wrap {
  display: flex;
  flex-direction: column;
  gap: 0px;
}

.map-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: var(--muted);
}

.map {
  display: grid;
/*   grid-template-columns: repeat(var(--map-cols, 5), 1fr);
 */  grid-template-columns: repeat(var(--map-cols, 5), 15px);
  gap: 0px;
}

.tile {
  font-size: 8pt;
  /* border-radius: 8px; */
  padding: 0px;;
  text-align: center;
  justify-content: center;
  border: 1px solid var(--border);
  min-width: 15px;
  max-width: 15px;
  width: 15px;
  min-height: 15px;
  max-height: 15px;
  height: 15px; 
  text-transform: capitalize;
}
.tile:hover {
  border-color: var(--accent);
  box-shadow: 0 6px 16px rgba(72, 199, 142, 0.25);
  cursor:not-allowed;
}

.tile.explored {
  background: #162535;
  color: var(--text);
}


.tile.current {
  border-color: var(--accent);
  border-width: 2px;;
  box-shadow: 0 6px 16px rgba(72, 199, 142, 0.35);
}
.tile.camp {
  border-radius: 3px;
  background: #23642f;
  color: #d4edda;
  border-color: #ffbf69;
}
.tile.forest {
  background: #317e3b;
  color: #a8d5a2;
}
.tile.mountain {
  background: #5a5a5a;
  color: #d1d1d1;
}
.tile.river {
  background: #3676bb;
}
.tile.lake {
  background: #2e5f99;
  color: #d1e7f5;
}
.tile.plain {
  background: #7c9f5a;
  color: #e2f0d9;
}
.tile.desert {
  background: #d2b98b;
  color: #5b3d1b;
}
.tile.swamp {
  background: #4a6b42;
  color: #c1d6b8;
}
.tile.tundra {
  background: #d4dce0;
  color: #2e3b44;
}
.tile.hills {
  background: #8b7d6b;
  color: #f0e8dc;
}
.tile.coast {
  background: #449fd8;
  color: #e1f0fb;
}
.tile.unexplored {
  background: #0c1118;
  color: #b6b8b9;
}



#biome {
  color: var(--accent);
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .left {
    grid-template-rows: auto;
  }
  .log {
    max-height: 160px;
  }
}



#goFS, #newGameBtn, #showLogBtn, #showInventoryBtn, #debugClearBtn {
    padding: 2px 8px;
    font-size: 11px;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}
#goFS {
  display: none;
  background-color: white;
  color: black;
}
#newGameBtn {
  background-color: #d9534f;
}
#showLogBtn {
  background-color: #5bc0de;
}
#debugClearBtn {
  background-color: #f0ad4e;
}

#showInventoryBtn {
  background-color: #6c757d;
}
#debugClearBtn:hover, #newGameBtn:hover, #showLogBtn:hover, #showInventoryBtn:hover, #goFS:hover {
  opacity: 0.8;
}

/* Popup Styles */
.popup {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.8);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.popup-content {
  background-color: var(--panel);
  border: 2px solid var(--accent);
  border-radius: 8px;
  max-width: 600px;
  max-height: 80vh;
  width: 90%;
  display: flex;
  flex-direction: column;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
}

.popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background-color: rgba(72, 199, 142, 0.1);
}

.popup-header h2 {
  margin: 0;
  color: var(--accent);
  font-size: 16px;
}

.close-popup {
  background: none;
  border: none;
  color: var(--text);
  font-size: 28px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.close-popup:hover {
  color: var(--accent);
}

.popup-body {
  padding: 16px;
  overflow-y: auto;
  flex: 1;
}

/* Log popup specific */
#logPopupContent {
  font-size: 11px;
  line-height: 1.6;
  color: var(--muted);
}

/* Inventory popup specific */
.popup-tools-grid,
.popup-inventory-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.popup-body .tools-panel h3,
.popup-body .inventory-panel h3 {
  margin-top: 16px;
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 14px;
}

.popup-body .tools-panel:first-child h3 {
  margin-top: 0;
}