逃走中チャレンジ
残り時間
060:00
現在の賞金
0 円
スタート
一時停止
リセット
自首
テーマ名
分
秒
1秒あたりの賞金 (円)
単価のみ変更
最初から設定
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>逃走中タイマー</title>
<style>
/* アニメーション用のみ */
@keyframes pulse {
0% { transform: scale(1); opacity: 1; }
50% { transform: scale(1.06); opacity: 0.9; }
100% { transform: scale(1); opacity: 1; }
}
@keyframes flash {
0% { box-shadow: 0 0 0 rgba(255,0,0,0); }
50% { box-shadow: 0 0 14px rgba(255,0,0,0.6); }
100% { box-shadow: 0 0 0 rgba(255,0,0,0); }
}
@keyframes wiggle {
0% { transform: rotate(-3deg); }
50% { transform: rotate(3deg); }
100% { transform: rotate(-3deg); }
}
@keyframes blink {
0% { opacity: 1; }
50% { opacity: 0.15; }
100% { opacity: 1; }
}
</style>
</head>
<body>
<div style="width:400px;height:400px;background:#000000;color:white;margin:10px;padding:12px;box-sizing:border-box;font-family: 'Courier New',Courier,monospace;overflow:auto;">
<!-- 1. テーマ名 -->
<div id="theme" style="text-align:center;font-size:20px;margin-bottom:10px;padding:6px 0;">
逃走中チャレンジ
</div>
<!-- 2. 残り時間ボックス -->
<div style="border:2px solid #ffffff;background:#000000;padding:8px;margin-bottom:10px;display:flex;align-items:center;justify-content:space-between;box-sizing:border-box;height:64px;">
<div style="font-size:14px;white-space:nowrap;">残り時間</div>
<div id="timeDisplay" style="font-family: 'Courier New',Courier,monospace;font-size:34px;color:#ffffff;letter-spacing:2px;">
060:00
</div>
</div>
<!-- 3. 現在の賞金ボックス -->
<div style="background:#141414;border-left:6px solid #ff0000;padding:8px;margin-bottom:10px;display:flex;align-items:center;justify-content:space-between;box-sizing:border-box;height:64px;">
<div style="font-size:14px;white-space:nowrap;">現在の賞金</div>
<div id="moneyDisplay" style="font-family: 'Courier New',Courier,monospace;font-size:34px;color:#ffffff;letter-spacing:2px;">
0 円
</div>
</div>
<!-- 4. 操作ボタンエリア(2列×2段) -->
<div style="display:grid;grid-template-columns:1fr 1fr;grid-gap:10px;margin-bottom:10px;height:152px;">
<div id="startBtn" style="background:#ffffff;color:#000000;display:flex;align-items:center;justify-content:center;font-size:18px;border-radius:8px;cursor:pointer;user-select:none;animation: pulse 2s infinite;">
スタート
</div>
<div id="pauseBtn" style="background:#444444;color:#ffffff;display:flex;align-items:center;justify-content:center;font-size:18px;border-radius:8px;cursor:pointer;user-select:none;">
一時停止
</div>
<div id="resetBtn" style="background:#444444;color:#ffffff;display:flex;align-items:center;justify-content:center;font-size:18px;border-radius:8px;cursor:pointer;user-select:none;">
リセット
</div>
<div id="surrenderBtn" style="background:#444444;color:#ffffff;display:flex;align-items:center;justify-content:center;font-size:18px;border-radius:8px;cursor:pointer;user-select:none;">
自首
</div>
</div>
<!-- 5. 設定欄 -->
<div style="padding:8px;background:#000000;border-top:1px solid rgba(255,255,255,0.04);box-sizing:border-box;">
<div style="display:flex;flex-direction:column;gap:6px;">
<div style="display:flex;justify-content:space-between;align-items:center;">
<div style="font-size:13px;">テーマ名</div>
<input id="themeInput" style="width:220px;background:#111111;color:#fff;border:1px solid #333333;padding:6px;border-radius:6px;font-family:inherit;font-size:13px;" value="逃走中チャレンジ">
</div>
<div style="display:flex;justify-content:space-between;align-items:center;">
<div style="font-size:13px;">分</div>
<input id="minInput" type="number" min="0" style="width:220px;background:#111111;color:#fff;border:1px solid #333333;padding:6px;border-radius:6px;font-family:inherit;font-size:13px;" value="60">
</div>
<div style="display:flex;justify-content:space-between;align-items:center;">
<div style="font-size:13px;">秒</div>
<input id="secInput" type="number" min="0" max="59" style="width:220px;background:#111111;color:#fff;border:1px solid #333333;padding:6px;border-radius:6px;font-family:inherit;font-size:13px;" value="00">
</div>
<div style="display:flex;justify-content:space-between;align-items:center;">
<div style="font-size:13px;">1秒あたりの賞金 (円)</div>
<input id="perSecInput" type="number" min="0" style="width:220px;background:#111111;color:#fff;border:1px solid #333333;padding:6px;border-radius:6px;font-family:inherit;font-size:13px;" value="10">
</div>
<div style="display:flex;gap:8px;justify-content:flex-end;">
<div id="applyUnitBtn" style="background:#222222;color:#ffffff;padding:8px 10px;border-radius:6px;cursor:pointer;user-select:none;animation: wiggle 3s infinite ease-in-out;">
単価のみ変更
</div>
<div id="applyAllBtn" style="background:#222222;color:#ffffff;padding:8px 10px;border-radius:6px;cursor:pointer;user-select:none;animation: flash 3s infinite;">
最初から設定
</div>
</div>
</div>
</div>
<!-- 小さな注記(スクロール許可のための余白) -->
<div style="height:8px;"></div>
</div>
<script>
(function(){
// Elements
const themeEl = document.getElementById('theme');
const themeInput = document.getElementById('themeInput');
const timeDisplay = document.getElementById('timeDisplay');
const moneyDisplay = document.getElementById('moneyDisplay');
const minInput = document.getElementById('minInput');
const secInput = document.getElementById('secInput');
const perSecInput = document.getElementById('perSecInput');
const startBtn = document.getElementById('startBtn');
const pauseBtn = document.getElementById('pauseBtn');
const resetBtn = document.getElementById('resetBtn');
const surrenderBtn = document.getElementById('surrenderBtn');
const applyUnitBtn = document.getElementById('applyUnitBtn');
const applyAllBtn = document.getElementById('applyAllBtn');
// State
let totalSeconds = 60*60; // default 60:00
let remaining = totalSeconds;
let perSec = Number(perSecInput.value) || 0;
let money = 0;
let timerId = null;
let running = false;
// Utility: format as MM:SS or HMM:SS for 100+ minutes? requirement: show minutes as minutes (e.g., 60 minutes)
function formatTime(sec){
if (sec < 0) sec = 0;
const mins = Math.floor(sec/60);
const secs = sec % 60;
// minutes may be >=100 -> show full digits
let minStr = String(mins).padStart(mins < 100 ? 2 : 0, '0');
// Special rule: "時間が100分切ったら一番左の0は消す. 10分切ったら一番左の0そのままで"
// Interpret: when minutes < 100, do not show leading hundreds 0 (i.e., for <100 remove leftmost 0). When <10, keep leading 0.
// We'll implement: if mins < 100 and minStr.length>=3 -> trim? Simpler: for mins < 100 display with at least 2 digits; if mins>=100 show full (no padding).
if (mins < 100){
minStr = String(mins).padStart(2,'0');
// If mins < 10, we keep leftmost 0 (as per "10分切ったら一番左の0そのままで")
// If 10<=mins<100, show two digits (no extra leading 0 beyond two).
} else {
minStr = String(mins); // 100+ show full digits
}
const secStr = String(secs).padStart(2,'0');
return minStr + ':' + secStr;
}
function renderTime(){
timeDisplay.textContent = formatTime(remaining);
}
function renderMoney(){
moneyDisplay.textContent = Math.floor(money).toLocaleString() + ' 円';
}
// Accurate 1-second tick: use setInterval but align with system clock to avoid drift
function startTimer(){
if (running) return;
running = true;
startBtn.style.transform = 'scale(1.02)';
startBtn.style.animation = 'none';
// immediate tick not to lose one second
scheduleNextTick();
}
function scheduleNextTick(){
if (!running) return;
// calculate ms to next full second
const now = performance.now();
const delay = 1000 - (Math.floor(now) % 1000);
timerId = setTimeout(() => {
tick();
scheduleNextTick();
}, delay);
}
function tick(){
// advance exactly 1 second
if (!running) return;
remaining = Math.max(0, remaining - 1);
money += perSec;
renderTime();
renderMoney();
// visual reactions when low time
if (remaining <= 0){
stopTimer();
// flash time display
timeDisplay.style.animation = 'blink 1s infinite';
// small celebratory wiggle for surrender button area
surrenderBtn.style.animation = 'wiggle 0.6s infinite';
} else if (remaining <= 10*60){
// intense blinking when < 10 minutes
timeDisplay.style.animation = 'flash 1.2s infinite';
} else if (remaining < 100*60){
timeDisplay.style.animation = 'pulse 2s infinite';
}
}
function stopTimer(){
running = false;
if (timerId) {
clearTimeout(timerId);
timerId = null;
}
startBtn.style.transform = '';
startBtn.style.animation = 'pulse 2s infinite';
}
// Buttons
startBtn.addEventListener('click', ()=>{
startTimer();
startBtn.style.boxShadow = '0 6px 12px rgba(255,255,255,0.06)';
setTimeout(()=>{ startBtn.style.boxShadow = ''; },300);
});
pauseBtn.addEventListener('click', ()=>{
stopTimer();
pauseBtn.style.transform = 'scale(0.98) rotate(-1deg)';
pauseBtn.style.animation = 'none';
setTimeout(()=>{ pauseBtn.style.transform = ''; },220);
});
resetBtn.addEventListener('click', ()=>{
stopTimer();
remaining = totalSeconds;
money = 0;
renderTime();
renderMoney();
timeDisplay.style.animation = '';
surrenderBtn.style.animation = '';
resetBtn.style.transform = 'scale(0.98)';
setTimeout(()=>{ resetBtn.style.transform = ''; },160);
});
surrenderBtn.addEventListener('click', ()=>{
// 自首: stop and lock remaining and award? We'll stop and show final money and bright flash.
stopTimer();
surrenderBtn.style.animation = 'flash 1s 3';
surrenderBtn.style.transform = 'scale(1.04)';
setTimeout(()=>{ surrenderBtn.style.transform=''; },600);
// small effect on money display
moneyDisplay.style.animation = 'pulse 0.8s 3';
setTimeout(()=>{ moneyDisplay.style.animation = ''; },2400);
});
// Settings buttons
applyUnitBtn.addEventListener('click', ()=>{
const newPer = Number(perSecInput.value) || 0;
perSec = newPer;
// Continue without resetting money or remaining
applyUnitBtn.style.transform = 'rotate(-6deg) scale(0.98)';
setTimeout(()=>{ applyUnitBtn.style.transform=''; },220);
});
applyAllBtn.addEventListener('click', ()=>{
// Apply all: set theme, time, perSec and reset timer & money
const m = Math.max(0, parseInt(minInput.value) || 0);
const s = Math.min(59, Math.max(0, parseInt(secInput.value) || 0));
totalSeconds = m*60 + s;
remaining = totalSeconds;
perSec = Number(perSecInput.value) || 0;
money = 0;
themeEl.textContent = themeInput.value || '逃走中チャレンジ';
renderTime();
renderMoney();
timeDisplay.style.animation = '';
surrenderBtn.style.animation = '';
stopTimer();
applyAllBtn.style.transform = 'scale(0.98)';
setTimeout(()=>{ applyAllBtn.style.transform=''; },200);
});
// Initialize render
function initFromInputs(){
const m = Math.max(0, parseInt(minInput.value) || 0);
const s = Math.min(59, Math.max(0, parseInt(secInput.value) || 0));
totalSeconds = m*60 + s;
remaining = totalSeconds;
perSec = Number(perSecInput.value) || 0;
money = 0;
themeEl.textContent = themeInput.value || '逃走中チャレンジ';
renderTime();
renderMoney();
}
initFromInputs();
// Prevent double activation on touch: add touch events mirroring click
[startBtn,pauseBtn,resetBtn,surrenderBtn,applyUnitBtn,applyAllBtn].forEach(el=>{
el.addEventListener('touchstart', (e)=>{ e.preventDefault(); el.click(); }, {passive:false});
});
// Ensure 1-second tick remains accurate across tab changes: nothing else to add; using performance.now alignment.
// Also ensure scrolling is allowed (do not prevent it). No images or emoji used.
})();
</script>
</body>
</html>