@import url('https://fonts.googleapis.com/css2?family=Architects+Daughter&family=Caveat:wght@700&display=swap');

:root {
  --color-ink-black: #111111;
  --color-ink-blue: #0f2c8d;
  --color-ink-red: #d11a2a;
  --color-paper: #fbf9f4;
  --font-hand: 'Architects Daughter', 'Caveat', cursive, sans-serif;
}

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

body {
  background-color: #e5e2d9;
  font-family: var(--font-hand);
  color: var(--color-ink-black);
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
}

/* Notebook paper wrapper */
.notebook-sheet {
  background-color: var(--color-paper);
  background-image: 
    linear-gradient(rgba(15, 44, 141, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(209, 26, 42, 0.2) 1px, transparent 1px);
  background-size: 100% 24px, 100% 100%;
  background-position: 0 0, 70px 0;
  width: 1200px;
  height: 675px;
  position: relative;
  border: 1px solid #dcd9d0;
  box-shadow: 10px 10px 30px rgba(0, 0, 0, 0.15);
  overflow: hidden;
  border-radius: 4px;
}

/* Spiral binder holes on the left to complete the notebook look */
.notebook-sheet::before {
  content: '';
  position: absolute;
  left: 20px;
  top: 0;
  bottom: 0;
  width: 20px;
  background-image: radial-gradient(circle, #e5e2d9 5px, transparent 6px);
  background-size: 20px 35px;
  background-position: center;
  z-index: 10;
  pointer-events: none;
  opacity: 0.65;
}

/* Screen Layouts */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  z-index: 20;
  background: transparent;
  padding: 40px;
}

.screen.hidden {
  display: none !important;
}

/* Sketchy Borders & Components */
.sketch-panel {
  background: rgba(251, 249, 244, 0.95);
  border: 3px solid var(--color-ink-black);
  border-radius: 255px 15px 225px 15px/15px 225px 15px 255px; /* Sketchy hand-drawn border effect */
  padding: 30px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 5px 5px 0px rgba(0, 0, 0, 0.15);
  max-width: 480px;
  width: 100%;
  text-align: center;
}

h1 {
  font-family: 'Caveat', cursive;
  font-size: 3.5rem;
  color: var(--color-ink-blue);
  margin-bottom: 20px;
  text-transform: uppercase;
  transform: rotate(-1.5deg);
  text-shadow: 2px 2px 0px rgba(15, 44, 141, 0.1);
}

h2 {
  font-family: 'Caveat', cursive;
  font-size: 2.2rem;
  color: var(--color-ink-red);
  margin-bottom: 15px;
  transform: rotate(0.8deg);
}

.sketch-input {
  width: 100%;
  padding: 10px 15px;
  font-family: var(--font-hand);
  font-size: 1.2rem;
  background: transparent;
  border: 2px solid var(--color-ink-blue);
  border-radius: 120px 20px 100px 25px/25px 110px 20px 120px;
  outline: none;
  color: var(--color-ink-black);
  margin-bottom: 20px;
  text-align: center;
}

.sketch-input:focus {
  border-color: var(--color-ink-red);
}

.sketch-btn {
  font-family: var(--font-hand);
  font-size: 1.3rem;
  padding: 8px 25px;
  background: transparent;
  color: var(--color-ink-blue);
  border: 3px solid var(--color-ink-blue);
  border-radius: 255px 15px 225px 15px/15px 225px 15px 255px;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  font-weight: bold;
}

.sketch-btn:hover {
  color: var(--color-ink-red);
  border-color: var(--color-ink-red);
  transform: scale(1.05) rotate(1deg);
  box-shadow: 2px 3px 0px rgba(209, 26, 42, 0.2);
}

.sketch-btn:active {
  transform: scale(0.98);
}

.sketch-btn.secondary {
  color: var(--color-ink-black);
  border-color: var(--color-ink-black);
  font-size: 1.1rem;
  margin-top: 15px;
}

.sketch-btn.secondary:hover {
  color: var(--color-ink-blue);
  border-color: var(--color-ink-blue);
}

/* Admin Link */
.admin-trigger {
  position: absolute;
  bottom: 20px;
  right: 30px;
  color: rgba(17, 17, 17, 0.4);
  font-size: 0.9rem;
  cursor: pointer;
  text-decoration: underline;
  z-index: 25;
}
.admin-trigger:hover {
  color: var(--color-ink-red);
}

/* GAME CANVAS & HUD OVERLAYS */
#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 10;
  cursor: none; /* Hide default pointer in game */
}

/* HUD elements container */
.hud-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* Let clicks pass through to canvas */
  z-index: 15;
}

.hud-layer * {
  pointer-events: auto; /* enable interaction for hud elements if needed */
}

/* TOP LEFT: Top 5 Ranking */
.hud-ranking {
  position: absolute;
  top: 25px;
  left: 90px; /* Keep to the right of binder spiral holes */
  width: 220px;
  background: rgba(251, 249, 244, 0.85);
  border: 2px solid var(--color-ink-black);
  border-radius: 15px 55px 15px 45px/45px 15px 55px 15px;
  padding: 10px 15px;
  font-size: 0.95rem;
}
.hud-ranking h3 {
  font-size: 1.2rem;
  color: var(--color-ink-blue);
  border-bottom: 1px dashed var(--color-ink-black);
  margin-bottom: 5px;
  font-family: 'Caveat', cursive;
  text-align: center;
}
.hud-ranking ol {
  padding-left: 20px;
}
.hud-ranking li {
  margin-bottom: 3px;
  font-weight: bold;
}

/* TOP RIGHT: Killfeed */
.hud-killfeed {
  position: absolute;
  top: 25px;
  right: 25px;
  width: 320px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  pointer-events: none;
}
.killfeed-item {
  background: rgba(251, 249, 244, 0.9);
  border: 1px solid var(--color-ink-red);
  border-radius: 4px;
  padding: 3px 8px;
  margin-bottom: 5px;
  font-size: 0.9rem;
  font-weight: bold;
  color: var(--color-ink-black);
  animation: slideIn 0.3s ease forwards;
}

/* TOP CENTER: Round timer countdown */
.hud-timer {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2.2rem;
  font-family: 'Caveat', cursive;
  color: var(--color-ink-red);
  font-weight: bold;
  background: rgba(251, 249, 244, 0.85);
  border: 2px solid var(--color-ink-red);
  border-radius: 5px 25px 5px 25px/25px 5px 25px 5px;
  padding: 2px 15px;
}

/* BOTTOM LEFT: Chat only */
.hud-bottom-left {
  position: absolute;
  bottom: 15px;
  left: 80px;
  width: 280px;
  display: flex;
  flex-direction: column;
  z-index: 15;
}

/* HP Bar */
.hud-hp-container {
  display: flex;
  flex-direction: column;
  background: rgba(251, 249, 244, 0.95);
  border: 2px solid var(--color-ink-black);
  border-radius: 5px;
  padding: 5px 10px;
  width: 250px;
}
.hud-hp-label {
  font-size: 0.9rem;
  font-weight: bold;
  margin-bottom: 2px;
}
.hud-hp-bar-bg {
  width: 100%;
  height: 14px;
  background: #eae6db;
  border: 1.5px solid var(--color-ink-black);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.hud-hp-bar-fill {
  height: 100%;
  background-color: var(--color-ink-red);
  width: 100%;
  transition: width 0.15s ease-out;
}

/* Chat Counter Strike style */
.hud-chat {
  background: transparent;
  border: none;
  padding: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}

/* BOTTOM CENTER: HP Bar */
.hud-bottom-center {
  position: absolute;
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 15;
}
.chat-messages {
  height: 110px;
  overflow-y: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  font-size: 0.85rem;
  margin-bottom: 5px;
}
.chat-msg {
  margin-top: 2px;
  word-break: break-all;
  font-weight: bold;
  transition: opacity 0.5s ease;
}
.chat-msg-sender {
  color: var(--color-ink-blue);
}
.chat-input-box {
  width: 100%;
  border: 1.5px solid var(--color-ink-black);
  border-radius: 4px;
  padding: 4px 8px;
  font-family: var(--font-hand);
  font-size: 0.85rem;
  background: transparent;
  outline: none;
}

/* CENTER ANNOUNCEMENTS (Multikill etc) */
.hud-announcement {
  position: absolute;
  top: 35%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  font-family: 'Caveat', cursive;
  font-size: 4.5rem;
  font-weight: bold;
  color: var(--color-ink-red);
  text-shadow: 3px 3px 0px rgba(0,0,0,0.1);
  text-align: center;
  pointer-events: none;
  opacity: 0;
  transition: all 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  transform-origin: center;
}
.hud-announcement.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1.2);
  animation: shake 0.3s infinite;
}

/* SCREEN FLASHER (Respawn / Hit indicator) */
.screen-flash {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 12;
  opacity: 0;
  transition: opacity 0.1s ease-out;
}
.screen-flash.active {
  opacity: 0.45;
}

/* ESC MENU OVERLAY */
.esc-menu {
  background: rgba(241, 238, 230, 0.96);
  border: 4px solid var(--color-ink-black);
  border-radius: 20px 85px 20px 75px/75px 20px 85px 20px;
  padding: 35px;
  width: 320px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 15px;
  box-shadow: 0px 8px 24px rgba(0,0,0,0.2);
}

/* MAP EDITOR PANEL */
.editor-container {
  display: flex;
  flex-direction: row;
  width: 100%;
  height: 100%;
  background: var(--color-paper);
}

.editor-sidebar {
  width: 250px;
  height: 100%;
  border-right: 3px solid var(--color-ink-black);
  padding: 20px 15px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 20px;
  background: rgba(251, 249, 244, 0.95);
  z-index: 15;
  overflow-y: auto;
}

.editor-tools {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}

.tool-section {
  border: 1.5px dashed var(--color-ink-black);
  padding: 10px;
  border-radius: 5px;
}
.tool-section-title {
  font-size: 0.9rem;
  font-weight: bold;
  color: var(--color-ink-blue);
  margin-bottom: 8px;
}

.tool-btn {
  width: 100%;
  padding: 6px 12px;
  border: 2px solid var(--color-ink-black);
  background: transparent;
  cursor: pointer;
  font-family: var(--font-hand);
  font-size: 0.95rem;
  font-weight: bold;
  text-align: left;
  border-radius: 3px;
  margin-bottom: 5px;
  transition: all 0.15s ease;
}
.tool-btn:hover {
  background: rgba(15, 44, 141, 0.05);
}
.tool-btn.active {
  background: var(--color-ink-blue);
  color: white;
  border-color: var(--color-ink-blue);
}
.tool-btn.red-tool.active {
  background: var(--color-ink-red);
  color: white;
  border-color: var(--color-ink-red);
}

.editor-canvas-container {
  flex-grow: 1;
  position: relative;
  height: 100%;
  overflow: hidden;
}

#editorCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  cursor: crosshair;
}

/* SETTINGS ADMIN PANEL */
.settings-panel {
  max-width: 600px;
  width: 100%;
  max-height: 90%;
  overflow-y: auto;
  padding: 25px 35px;
}

.settings-form {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin-top: 15px;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dashed rgba(17, 17, 17, 0.2);
  padding-bottom: 8px;
}

.settings-label {
  font-size: 1.1rem;
  font-weight: bold;
}
.settings-label span {
  display: block;
  font-size: 0.85rem;
  color: rgba(17, 17, 17, 0.6);
  font-weight: normal;
}

.settings-input {
  width: 120px;
  padding: 5px;
  font-family: var(--font-hand);
  font-size: 1rem;
  border: 2px solid var(--color-ink-blue);
  border-radius: 4px;
  background: transparent;
  text-align: center;
}

.settings-select {
  width: 120px;
  padding: 5px;
  font-family: var(--font-hand);
  font-size: 1rem;
  border: 2px solid var(--color-ink-blue);
  border-radius: 4px;
  background: transparent;
  cursor: pointer;
}

.settings-actions {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  margin-top: 10px;
}

/* KEYFRAMES & ANIMATIONS */
@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes shake {
  0% { transform: translate(-50%, -50%) rotate(0deg) scale(1.2); }
  25% { transform: translate(-50%, -50%) rotate(-1deg) scale(1.2); }
  50% { transform: translate(-50%, -50%) rotate(1deg) scale(1.2); }
  75% { transform: translate(-50%, -50%) rotate(-0.5deg) scale(1.2); }
  100% { transform: translate(-50%, -50%) rotate(0.5deg) scale(1.2); }
}
