@import url('https://fonts.googleapis.com/css2?family=Bungee&family=Press+Start+2P&display=swap');

/* =========================================================
   GLOBAL RESET / BASE
   ========================================================= */

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  padding: 0;
  font-family: 'Bungee', cursive;
  color: #222;
  background: url('background/br1.png') repeat;
  overflow: hidden; /* app controls scrolling per panel */
}

/* =========================================================
   APP LAYOUT: 75% (sheet/show) + 25% (chat)
   ========================================================= */

#app-content {
  display: flex;
  flex-direction: row;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* Left lane: character sheet OR show panel (same size) */
#main-container,
#show-panel {
  flex: 0 0 75%;
  width: 75%;
  max-width: 75%;
  height: 100vh;
  overflow: hidden;
}

/* Character sheet container */
#main-container {
  background-color: rgba(144, 238, 144, 0.7);
  border-radius: 12px;
  padding: 10px;
  padding-top: 60px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Show panel container (hidden unless active) */
#show-panel {
  display: none; /* JS shows it */
  background: #111;
  padding: 20px;
  padding-top: 40px;
}

/* Chat lane */
#chat-panel {
  flex: 0 0 25%;
  width: 25%;
  max-width: 25%;
  height: 100vh;

  display: none; /* JS shows it when in session */
  flex-direction: column;

  background: #222;
  color: #fff;
  border-left: 2px solid #555;
  overflow: hidden;
}

#chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 10px;
}

#chatInput {
  background: #111;
  color: #fff;
}

/* Safety: panels should never overlap via positioning */
#character-panel { display: block; }

/* =========================================================
   TITLE
   ========================================================= */

.title-wrapper { text-align: center; }

h1 {
  text-align: center;
  display: inline-block;
  padding: 10px 15px;
  background-color: #00e5ff;
  box-shadow: 4px 4px #000;
  border-radius: 0;
  font-size: 3.1em;
  color: #ff00ff;
  text-shadow: 2px 2px 0 #000;
  margin: 0 0 20px 0;
}

/* =========================================================
   BUTTONS / INPUTS
   ========================================================= */

button {
  font-family: 'Press Start 2P', cursive;
  font-size: 12px;
  padding: 10px 14px;
  margin: 5px;
  border: 3px solid #000;
  background-color: #00e5ff;
  color: #000;
  box-shadow: 3px 3px #000;
  cursor: pointer;
  transition: all 0.2s ease;
}

button:hover {
  background-color: #ff00ff;
  color: #fff;
  transform: scale(1.05);
}

button:disabled,
input:disabled,
textarea:disabled,
select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none !important;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
  font-family: monospace;
  font-size: 16px;
  padding: 6px;
  border: 2px solid #000;
  background-color: #fff6d1;
  margin-bottom: 8px;
  box-shadow: inset 2px 2px #888;
  outline: none;
}

textarea {
  width: 100%;
  height: 100px;
}

/* =========================================================
   LABELS / SECTION HEADERS
   ========================================================= */

label, h2 {
  background-color: rgba(255, 255, 0, 0.7);
  padding: 4px 8px;
  border-radius: 6px;
  display: inline-block;
}

.section-label {
  font-size: 2em;
  font-family: 'Bungee', cursive;
  background-color: rgba(255, 255, 0, 0.7);
  padding: 4px 12px;
  border-radius: 6px;
  display: inline-block;
  margin: 6px 0;
}

.section-title { font-size: 1.95em; }
.skills-title  { font-size: 2.535em; }

/* =========================================================
   NAME BLOCK (NAME label above row + bigger portrait)
   ========================================================= */

/* The NAME area should look like:
   [NAME label]
   [portrait][name input]
*/
.name-row{
  display:flex;
  align-items:center;
  gap:12px;
  margin-top: 10px;
  margin-bottom: 14px;
}

/* NAME label: shrink-wrap to text instead of stretching wide */
.name-input-col .section-label{
  display: inline-block;
  width: fit-content;   /* or just remove width if it exists elsewhere */
  margin: 0 0 6px 0;    /* optional: small gap above input */
  padding: 4px 12px;    /* keep the nice label padding */
}



.portrait-wrap{
  position: relative;
  width: 128px;
  height: 128px;
  flex: 0 0 128px;
}

.portrait-img{
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  border-radius: 12px;
  background: #222;
  border: 3px solid #000;
  box-shadow: 3px 3px #000;
}

/* Right column = NAME label above input */
.name-input-col{
  display:flex;
  flex-direction:column;
  gap:6px;
  flex: 1 1 auto;
  min-width: 0;
}

/* Upload badge pinned to portrait corner */
.portrait-upload-btn{
  position: absolute;
  right: -12px;
  bottom: -12px;

  width: 34px;
  height: 34px;

  display: flex;
  align-items: center;
  justify-content: center;

  padding: 0;
  border-radius: 999px;

  background: #00e5ff !important;
  color: #000;

  border: 3px solid #000;
  box-shadow: 2px 2px #000;
  cursor: pointer;

  font-size: 14px;
  line-height: 1;
}

.portrait-upload-btn:hover{
  background: #ff00ff !important;
  color: #fff;
}

.portrait-upload-btn input{ display: none; }

#player-name{
  width: 100%;
  max-width: 560px;
  min-width: 0;

  font-family: monospace;
  font-size: 30px;
  font-weight: bold;
  padding: 8px;
  height: 48px;

  border: 2px solid #000;
  background-color: #fff6d1;
  box-shadow: inset 2px 2px #888;
}
/* =========================================================
   SKILLS / ITEMS / CONDITIONS
   ========================================================= */

#skills-container,
#items-container,
#conditions-container {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 15px;
}

.input-wrapper {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.skill-levels {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}

.skill-level { accent-color: #ff00ff; }

.skill-input,
.item-input,
.condition-input {
  width: 250px;
  font-size: 16px;
  padding: 6px;
  font-family: monospace;
  border: 2px solid #000;
  background-color: #fff6d1;
  box-shadow: inset 2px 2px #888;
  margin: 4px 0;
}

.delete-button {
  margin-top: 4px;
  background-color: #ff0000;
  color: #fff;
  font-size: 14px;
  border: 3px solid #000;
  padding: 4px 8px;
  box-shadow: 2px 2px #000;
}

.delete-button:hover { background-color: #b30000; }

/* =========================================================
   COUNTERS / WOUNDS
   ========================================================= */

#counters-section {
  display: flex;
  flex-wrap: wrap;
  gap: 30px;
  margin-bottom: 20px;
}

.counter-block h2 {
  margin: 0;
  font-size: 1.2em;
  text-align: center;
}

.counter {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 20px;
  font-weight: bold;
  padding-top: 5px;
}

.wounds-section {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.wounds {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.wounds button {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: #ccc;
  color: #000;
  font-weight: bold;
  border: 2px solid #000;
  cursor: pointer;
  box-shadow: 2px 2px #000;
}

.wounds button.active {
  background-color: darkred;
  color: #fff;
}

.buy-luck-btn {
  padding: 0 8px;
  line-height: 3;
}


/* =========================================================
   RULES MODAL
   ========================================================= */

#rules-button {
  margin-bottom: 10px;
  background-color: #fff;
  color: #000;
  font-size: 14px;
  padding: 6px 10px;
}

.modal {
  display: none;
  position: fixed;
  z-index: 3000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.7);
}

.modal-content {
  background-color: #fff;
  margin: 5% auto;
  padding: 20px;
  width: 80%;
  max-width: 700px;
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 3px solid #000;
  box-shadow: 6px 6px #000;
}

.modal-content img {
  max-width: 100%;
  margin: 10px 0;
}

.close {
  align-self: flex-end;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
}

.rules-body{
  width: 100%;
  max-height: 75vh;
  overflow-y: auto;
  padding-right: 8px;
}

.rules-body h2,
.rules-body h3,
.rules-body h4{
  width: 100%;
  text-align: left;
  margin: 12px 0 6px;
}

.rules-body p,
.rules-body li{
  font-size: 14px;
  line-height: 1.5;
}

.rules-table{
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 14px;
  font-size: 14px;
}

.rules-table th,
.rules-table td{
  border: 2px solid #000;
  padding: 6px 8px;
  text-align: left;
}

/* =========================================================
   GM TOOLS BUTTON
   ========================================================= */

#gm-tools-button {
  font-family: 'Press Start 2P', cursive;
  font-size: 12px;
  padding: 6px 12px;
  background-color: #00e5ff;
  border: 2px solid #000;
  box-shadow: 2px 2px #000;
  color: #000;
  cursor: pointer;
}

/* =========================================================
   SHOW & TELL / TABS / PAN-ZOOM / DRAW CANVAS
   ========================================================= */

#zoom-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#zoom-content {
  display: flex;
  flex-direction: column;
  height: 100%;
  gap: 10px;
  min-height: 0; /* critical for flex children scroll math */
}

#tab-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

#tab-bar {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 10px;
  gap: 5px;
}

.tab-button {
  background: #444;
  color: #fff;
  border: 2px solid #000;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  box-shadow: 2px 2px #000;
}

.tab-button.active {
  background: #ffa500;
  color: #000;
}

#image-display-area {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  overflow: hidden;
  margin: 0 auto;
  width: 100%;
  border: 2px solid #333;
  border-radius: 8px;
  background: #0b0b0b;

  cursor: grab;
  user-select: none;
  touch-action: none;
}

#panzoom-layer {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

#tab-image {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  max-width: none;
  max-height: none;
  margin: 0;
  border: 2px solid #ccc;
  border-radius: 8px;

  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}

/* Canvas: default off for pointer events so panning works.
   Enable by adding .draw-active to #image-display-area in JS */
#draw-canvas {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 5;
  pointer-events: none;
  touch-action: none;
}

#image-display-area.draw-active #draw-canvas {
  pointer-events: auto;
  cursor: crosshair;
}

#image-display-area.draw-active {
  cursor: crosshair;
}
