@font-face {
  font-family: 'Regar Demo';
  src: url('assets/fonts/RegarDemo-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'Bogle';
  src: url('assets/fonts/BogleWeb-Regular.woff') format('woff'),
       url('assets/fonts/BOGLEREGULAR.OTF') format('opentype');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'Bogle';
  src: url('assets/fonts/BogleWeb-Bold.woff') format('woff'),
       url('assets/fonts/BOGLEBOLD.OTF') format('opentype');
  font-weight: bold;
  font-style: normal;
}
@font-face {
  font-family: 'Bogle';
  src: url('assets/fonts/BogleWeb-RegularItalic.woff') format('woff'),
       url('assets/fonts/BOGLEITALIC.OTF') format('opentype');
  font-weight: normal;
  font-style: italic;
}
@font-face {
  font-family: 'Bogle';
  src: url('assets/fonts/BogleWeb-BoldItalic.woff') format('woff'),
       url('assets/fonts/BOGLEBOLDITALIC.OTF') format('opentype');
  font-weight: bold;
  font-style: italic;
}
:root {
  --bg: #f4f6fb;
  --card-bg: #ffffff;
  --card-shadow: 0 6px 18px rgba(17, 24, 39, 0.08);
  --border-color: #cbd5f5;
  --primary: #00385C;
  --primary-dark: #002753;
  --accent: #f1c8aa;
  --danger: #F15921;
  --text: #212121;
  --muted: #666666;
  --title: #436337;
  --card-title: #60A44C;
  font-size: 16px;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  width: 100%;
  margin: 0;
  padding: 0;
  overflow: hidden;
}

body {
  font-family: 'Bogle', "Segoe UI", "Roboto", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  flex-direction: column;
}

.wbackground { 
  background-color: #ffb74d;
  background-image: url("assets/images/bg3.jpg");
  background-repeat: no-repeat;
  background-size: 100% 100%;
}

#game-container {
  display: flex;
  flex-direction: row;
  gap: 0;
  position: relative;
  z-index: 0;
  height: calc(100vh - 60px);
  width: 100vw;
  overflow: hidden;
  flex: 1;
  background-image: url("assets/images/bg3.jpg");
  background-size: cover;
  background-position: center center;
}

#placeholder-column {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  width: 25%;
  min-width: 25%;
  max-width: 25%;
  height: 100%;
  padding: 24px 12px 24px 24px;
  /* background: var(--bg); */
  background-color: rgba(244,246,251, 0.4);
  border-right: 2px solid var(--border-color);
  z-index: 0;
  isolation: isolate;
  overflow-y: auto;
  overflow-x: hidden;
}

#cards-container {
  position: relative;
  flex: 1;
  width: 75%;
  height: 100%;
  /* background: var(--bg); */
   background-color: rgba(244,246,251, 0.2);
  isolation: isolate;
  z-index: 1;
  overflow: hidden;
}

.action-btn {
  padding: 0.625rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(63, 81, 181, 0.25);
}

.action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  box-shadow: none;
}

.action-btn:not(:disabled):hover,
.action-btn:not(:disabled):focus {
  transform: translateY(-1px);
  background: var(--primary-dark);
}

#reset-btn {
  background: #fff;
  color: var(--primary);
  box-shadow: inset 0 0 0 2px var(--primary);
}

#reset-btn:hover {
  background: #eef2ff;
}

.placeholder-slot {
  border: 2px dashed var(--border-color);
  border-radius: 18px;
  height: 66px;
  background: rgba(255, 255, 255, 0.9);
  margin: 0 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-weight: 600;
  letter-spacing: 0.5px;
  transition: border-color 0.2s ease, background 0.2s ease, transform 0.2s ease;
  font-size: 1.6rem;
}

.placeholder-slot::after {
  content: attr(data-label);
  pointer-events: none;
  color: var(--muted);
}

.placeholder-slot.empty::after {
  content: attr(data-label) ' • Lohista siia';
}

.placeholder-slot.filled::after {
  display: none;
}

.placeholder-slot.filled {
  border-style: solid;
  border-color: var(--primary);
}

.placeholder-slot.highlight {
  border-color: var(--primary);
  background: #eef2ff;
  transform: translateY(-2px);
}

.arrow-indicator {
  height: 20px;
  position: relative;
  top: -3px;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  z-index: 100;
}

.arrow-indicator.active {
  opacity: 1;
  pointer-events: auto;
}

.arrow-indicator::before {
  content: "";
  display: block;
  width: 4px;
  height: 12px;
  background: var(--primary);
  margin: 0 auto;
  border-radius: 999px;
  transition: background 0.3s ease;
}

.arrow-indicator::after {
  content: "";
  display: block;
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-top: 12px solid var(--primary);
  margin: 2px auto 0 auto;
  transition: border-top-color 0.3s ease;
}

.arrow-indicator.hover::before {
  background: var(--primary);
}
.arrow-indicator.hover::after {
  border-top-color: var(--primary);
}

.arrow-indicator.comm::before {
  background: var(--danger);
}
.arrow-indicator.comm::after {
  border-top-color: var(--danger);
}

.card {
  position: absolute;
  width: 230px;
  min-height: 110px;
  background: var(--card-bg);
  border: 2px solid var(--primary);
  border-radius: 20px;
  padding: 1.2rem 1.2rem 1.4rem 1.2rem;
  box-shadow: var(--card-shadow);
  cursor: grab;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  touch-action: none;
  user-select: none;
}

.card:focus {
  outline: 3px solid var(--primary);
}

.card:hover {
  transform: none; /* avoid geometry shift that causes drag offset */
  box-shadow: 0 12px 26px rgba(15, 23, 42, 0.18);
}

.card.dragging {
  opacity: 0.85;
  cursor: grabbing;
  transform: none !important;
  z-index: 10000;
}

.card .card-title {
  font-size: 1.4rem;
  font-family: 'Bogle', Arial, sans-serif;
  font-weight: bold;
  margin: 0 0 0.25rem 0;
  color: var(--card-title);
  font-style: italic;
}

.card .card-subtitle {
  margin: 0;
  font-size: 1 rem;
  color: var(--muted);
  font-family: 'Bogle', Arial, sans-serif;
  font-style: normal;
}

.card .info-icon {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 22px;
  height: 22px;
  cursor: pointer;
  transition: transform 0.2s ease;
}

.card .info-icon:active,
.card .info-icon:hover {
  transform: scale(1.1);
}

img.modalimg {
  border: 0px;
  float: right;
  max-width: 40%;
  margin-left: 1rem;
  margin-bottom: 0.5rem;
}

/* Special card styled as a block arrow pointing downward */
.card.special {
  /* Override default card styles */
  border: 2px solid var(--danger);
  border-radius: 20px;
  background: var(--card-bg);
  box-shadow: var(--card-shadow);
  
  /* Dimensions */
  width: 300px;
  min-height: 110px;
  
  /* Positioning and interaction */
  position: absolute;
  cursor: grab;
  touch-action: none;
  user-select: none;
  
  /* Spacing */
  padding: 1.2rem 1.2rem 1.4rem 1.2rem;
  
  /* Transitions */
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  
  /* Color reference for potential SVG use */
  color: var(--accent);
  
  /* Alternative SVG arrow background (commented out) */
  /* background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='-51 -15 242 160'><path d='M-33 -15 H183 A8 8 0 0 1 191 -7 V100 A8 8 0 0 1 183 108 H85 V130 H91 L75 145 L59 130 H65 V108 H-33 A8 8 0 0 1 -41 100 V-7 A8 8 0 0 1 -33 -15 Z' fill='rgba(241, 200, 170, 0.55)' stroke='rgba(241, 89, 33, 1)' stroke-width='2' stroke-dasharray='3,3' stroke-linejoin='round' stroke-linecap='round'/></svg>"); */
  /* background-repeat: no-repeat; */
  /* background-size: 100% 100%; */
  /* padding: 1.2rem 1.6rem 3.6rem 1.6rem; */ /* Extra bottom padding for arrow stem/head */
}

/* Ensure text stays readable within clipped shape */
.card.special .card-title,
.card.special .card-subtitle {
  position: relative;
  z-index: 1;
}
.card.special .card-title{
  color: var(--danger);
}

.placeholder-slot .card {
  position: relative;
  width: 100%;
  min-height: auto;
  box-shadow: none;
  border: none;
  transform: none !important;
  cursor: grab;
  padding: 0.75rem 1rem;
}

/* Avoid double border effect on focused cards inside slots */
.placeholder-slot .card:focus,
.placeholder-slot .card:focus-visible,
.placeholder-slot .card:active {
  outline: none;
}

.placeholder-slot .card .card-subtitle {
  display: none;
}

.placeholder-slot .card .info-icon {
  display: block;
}

.placeholder-slot .card:hover {
  box-shadow: none;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  z-index: 1000;
}

.modal-open {
  overflow: hidden;
}

.modal[aria-hidden="false"] {
  display: flex;
}

.modal-content {
  position: relative;
  background: #ffffff;
  border-radius: 24px;
  padding: 2rem;
  /* max-width: 540px; */
  max-width: 80%;
  /* width: min(90vw, 560px); */
  max-height: min(80vh, 700px);
  overflow-y: auto;
  text-align: center;
  box-shadow: 0 24px 48px rgba(15, 23, 42, 0.25);
}

.modal-title {
  color: var(--card-title);
  font-style: normal;
  font-family: 'Bogle', Arial, sans-serif;
  font-size: 3rem;
  margin-bottom: 1rem;
  margin-top: 1.5rem;
}
.modal-subtitle {
  color: var(--muted);
  font-style: italic;
  font-family: 'Bogle', Arial, sans-serif;
  font-size: 2rem;
  margin-top: 1rem;
}

.modal-body {
  text-align: left;
  line-height: 1.6;
  margin-top: 1rem;
}

.modal-body p , .modal-body ul li{
  margin: 0.5rem 0;
  font-style: normal;
  font-family: 'Bogle', Arial, sans-serif;
  font-size: 1.3rem;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 2rem;
}

.primary,
.secondary {
  min-width: 120px;
  padding: 0.7rem 1.6rem;
  border-radius: 999px;
  border: none;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.primary {
  background: var(--primary);
  color: #fff;
  box-shadow: 0 8px 18px rgba(63, 81, 181, 0.3);
}

.primary:hover {
  transform: translateY(-1px);
  background: var(--primary-dark);
}

.secondary {
  background: #edf0ff;
  color: var(--primary);
  box-shadow: inset 0 0 0 2px rgba(63, 81, 181, 0.4);
}

.secondary:hover {
  transform: translateY(-1px);
  background: #e0e7ff;
}

.icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
}

.close-btn {
  position: absolute;
  top: 18px;
  right: 18px;
}

.close-btn img {
  width: 22px;
  height: 22px;
}

.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.875rem 1.5rem;
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  height: 100px;
  flex-shrink: 0;
}

.game-title {
  font-size: 3.5rem;
  margin: 0;
  color: var(--title);
  font-family: 'Regar Demo', Arial, sans-serif;
  font-weight: normal;
  text-transform: uppercase;
}

.top-actions {
  display: flex;
  gap: 0.75rem;
}

@media (max-width: 1100px) {
  #game-container {
    flex-direction: column-reverse;
    overflow-y: auto;
    overflow-x: hidden;
  }

  #placeholder-column {
    width: 100%;
    min-width: 100%;
    max-width: 100%;
    flex-shrink: 0;
    height: auto;
    max-height: 50vh;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
  }

  #cards-container {
    width: 100%;
    flex: 1;
    min-height: 400px;
    height: auto;
    overflow: visible;
  }

  .placeholder-slot {
    height: 60px;
    margin: 0.2rem 0;
  }

  .arrow-indicator {
    height: 32px;
  }

  .card {
    width: 180px;
  }
}

@media (max-width: 640px) {
  .top-bar {
    flex-direction: column;
    gap: 0.75rem;
    text-align: center;
    height: auto;
  }

  .top-actions {
    width: 100%;
    justify-content: center;
  }

  .card {
    width: 160px;
    padding: 1rem;
  }
}

/* Extra wide screens (4K and above) */
@media (min-width: 1921px) {
  .modal-content {
    max-width: 1100px;
  }
}

/* Portrait mode adjustments */
@media (orientation: portrait) {
  #game-container {
    background-size: auto 100%;
    background-position: center;
  }

  .modal-content {
    max-width: 92%;
    max-height: 88vh;
    padding: 1.5rem;
  }

  img.modalimg {
    float: none;
    display: block;
    max-width: 100%;
    width: 100%;
    margin: 1rem 0 0 0;
  }

  .modal-body {
    display: flex;
    flex-direction: column;
  }

  /* Move image to end of content in portrait */
  .modal-body img.modalimg {
    order: 1;
  }
}


/* Decorative image in bottom-right of cards area */
/* 
#cards-container::after {
  content: "";
  position: absolute;
  right: 16px;
  bottom: -30px;
  width: min(280px, 30%);
  aspect-ratio: 16 / 9;
  background-image: url("assets/images/waterlands.svg");
  background-repeat: no-repeat;
  background-size: contain;
  opacity: 0.95;
  pointer-events: none;
  z-index: -10;
  transform: translateZ(0);
}
*/

/* Ensure cards are painted above the decorative image */
.card { z-index: 5; }

/* Hide game areas when welcome screen active */
#cards-container.hidden, #placeholder-column.hidden {
  display: none !important;
}

/* Welcome / initial screen */
.welcome-screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 18, 0.35);
  z-index: 9999;
}
.welcome-panel {
  background: #ffffff;
  border-radius: 16px;
  padding: 2rem;
  max-width: 980px;
  width: calc(100% - 3rem);
  box-shadow: 0 30px 60px rgba(2,6,23,0.4);
  text-align: left;
}
.welcome-panel .welcome-subtitle {
  font-size: 1.25rem;
  color: var(--card-title);
  margin-top: 0;
}
.welcome-panel .welcome-subtitle.juhis {
  color: var(--card-title) !important;
  font-weight: 700;
}

/* Vertical layout: position welcome screen higher */
@media (max-width: 1100px) {
  .welcome-screen {
    align-items: flex-start;
    padding-top: 8vh;
  }
}

/* Blink animation for special card when auto-comm is triggered */
.card.blink {
  /* Fast blink cycle (0.6s) — JS will remove the class after a few seconds
     so the blink repeats multiple times during that window */
  animation: special-blink 0.6s linear infinite;
}
@keyframes special-blink {
  0% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
  100% { transform: translateY(0); }
}
.welcome-panel .welcome-body {
  margin-bottom: 1rem;
  font-size: 1.5rem;
  color: var(--text);
  line-height: 1.5;
}
.welcome-body-green {
  margin-bottom: 1rem;
  font-size: 1.5rem;
  color: var(--card-title);
  line-height: 1.5;
}
.welcome-panel .modal-actions { justify-content: center; margin-top: 1rem; }

/* ============ SCREENSAVER ============ */
.screensaver {
  position: fixed;
  inset: 0;
  background: #1a1a1a;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.screensaver[aria-hidden="true"] {
  display: none;
}

.screensaver-title {
  font-family: 'Regar Demo', Arial, sans-serif;
  font-size: 7rem;
  color: #4CAF50;
  text-transform: uppercase;
  text-align: center;
  padding: 2rem;
  max-width: 90%;
  position: absolute;
  opacity: 1;
  transition: opacity 1s ease-in-out;
}

.screensaver-title.fade-out {
  opacity: 0;
}

@media (max-width: 1100px) {
  .screensaver-title {
    font-size: 10.5rem;
    max-width: 70%;
    word-spacing: 100vw; /* Forces each word to its own line */
  }
}

@media (max-width: 640px) {
  .screensaver-title {
    font-size: 7rem;
    max-width: 80%;
    word-spacing: 100vw;
  }
}

/* ============ FEEDBACK TOAST ============ */
.feedback-toast {
  position: fixed;
  top: 50%;
  right: 37.5%; /* Center of the 75% width pool area */
  transform: translate(50%, -50%);
  background: rgba(241, 89, 33, 0.95);
  color: #fff;
  padding: 1.25rem 2.5rem;
  border-radius: 16px;
  font-size: 1.5rem;
  font-weight: 600;
  font-family: 'Bogle', Arial, sans-serif;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  z-index: 10000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.6s ease-in-out;
}

.feedback-toast.visible {
  opacity: 1;
}

/* Toast positioning for smaller screens where layout is column */
@media (max-width: 1100px) {
  .feedback-toast {
    top: 25%;
    right: 50%;
    transform: translate(50%, -50%);
  }
}

/* ============ WRONG SLOT INDICATOR ============ */
.placeholder-slot.wrong-blink {
  border-color: var(--danger) !important;
  border-style: solid !important;
  background: rgba(241, 89, 33, 0.2) !important;
  animation: slot-wrong-pulse 0.4s ease-in-out infinite;
}

@keyframes slot-wrong-pulse {
  0%, 100% {
    background: rgba(241, 89, 33, 0.15);
  }
  50% {
    background: rgba(241, 89, 33, 0.3);
  }
}

/* ============ SPECIAL CARD CENTER ANIMATION ============ */
.card.special.center-blink {
  animation: special-center-blink 0.8s ease-in-out infinite;
}

@keyframes special-center-blink {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.05);
    opacity: 0.7;
  }
}

/* ============ FLYING ARROW ANIMATION ============ */
.flying-arrow {
  font-size: 30px;
  color: #e67e22;
  font-weight: bold;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
  filter: drop-shadow(0 2px 4px rgba(230, 126, 34, 0.5));
}


/* @media (max-width: 1100px) {
  #cards-container::after {
    right: 12px;
    bottom: 12px;
    width: 200px;
    opacity: 0.85;
  }
}

@media (max-width: 640px) {
  #cards-container::after {
    right: 8px;
    bottom: 8px;
    width: 140px;
    opacity: 0.8;
  }
} */
